Skip to content

Commit a603ea0

Browse files
chore: PR #30 review fixes — remove .cursor artifact, async _delete via _call + 204
- Remove .cursor/plans/purely_async_er2er_f2b9c60a.plan.md (IDE artifact) - Add .cursor/ to .gitignore to prevent recurrence - Async _delete: delegate to _call() with 204 and DELETE 409 handling in _call - Update async test for 500 to accept ERClientInternalError message Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent f29091c commit a603ea0

4 files changed

Lines changed: 16 additions & 107 deletions

File tree

.cursor/plans/purely_async_er2er_f2b9c60a.plan.md

Lines changed: 0 additions & 68 deletions
This file was deleted.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,6 @@ ENV/
104104

105105
# Pycharm .idea folder
106106
.idea/
107+
108+
# Cursor IDE artifacts
109+
.cursor/

erclient/client.py

Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,44 +1686,10 @@ async def _get_data(self, endpoint, params, batch_size=0):
16861686
async def _get(self, path, base_url=None, params=None):
16871687
return await self._call(path=path, payload=None, method="GET", params=params, base_url=base_url)
16881688

1689-
async def _delete(self, path, base_url=None):
1690-
"""Issue DELETE request. Returns True on success; raises ERClient* on error."""
1691-
try:
1692-
auth_headers = await self.auth_headers()
1693-
except httpx.HTTPStatusError as e:
1694-
self._handle_http_status_error(path, "DELETE", e)
1695-
headers = {'User-Agent': self.user_agent, **auth_headers}
1696-
if not path.startswith('http'):
1697-
path = self._er_url(path, base_url)
1698-
try:
1699-
response = await self._http_session.delete(path, headers=headers)
1700-
except httpx.RequestError as e:
1701-
reason = str(e)
1702-
self.logger.error('Request to ER failed', extra=dict(provider_key=self.provider_key,
1703-
url=path,
1704-
reason=reason))
1705-
raise ERClientException(f'Request to ER failed: {reason}')
1706-
if response.is_success:
1707-
return True
1708-
if response.status_code == 404:
1709-
self.logger.error("404 when calling %s", path)
1710-
raise ERClientNotFound()
1711-
if response.status_code == 403:
1712-
try:
1713-
reason = response.json().get('status', {}).get('detail', 'unknown reason')
1714-
except Exception:
1715-
reason = 'unknown reason'
1716-
raise ERClientPermissionDenied(reason)
1717-
if response.status_code == 409:
1718-
try:
1719-
detail = response.json().get('detail', response.text)
1720-
except Exception:
1721-
detail = response.text
1722-
raise ERClientException(
1723-
f'Cannot delete: {detail}',
1724-
)
1725-
raise ERClientException(
1726-
f'Failed to delete: {response.status_code} {response.text}'
1689+
async def _delete(self, path, base_url=None, params=None):
1690+
"""Issue DELETE request via _call. Returns True on 204; raises ERClient* on error."""
1691+
return await self._call(
1692+
path=path, payload=None, method="DELETE", params=params, base_url=base_url
17271693
)
17281694

17291695
async def get_file(self, url):
@@ -1788,6 +1754,14 @@ async def _call(self, path, payload, method, params=None, base_url=None):
17881754
params=params,
17891755
headers=headers
17901756
)
1757+
if response.status_code == 204:
1758+
return True
1759+
if response.status_code == 409 and method == "DELETE":
1760+
try:
1761+
detail = response.json().get("detail", response.text)
1762+
except Exception:
1763+
detail = response.text
1764+
raise ERClientException(f"Cannot delete: {detail}")
17911765
response.raise_for_status()
17921766
except httpx.RequestError as e:
17931767
# Network errors, timeouts

tests/async_client/test_delete_event_type.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ async def test_delete_event_type_server_error_raises(er_client):
165165
text="Internal Server Error"
166166
)
167167

168-
with pytest.raises(ERClientException, match="Failed to delete"):
168+
with pytest.raises(ERClientException, match="500|Internal Server Error"):
169169
await er_client.delete_event_type(slug)
170170

171171
assert route.called

0 commit comments

Comments
 (0)