Skip to content

Commit a386f62

Browse files
committed
fix: use NotRequired for counts, remove duplicate status param, guard files/data kwargs
1 parent e8dda2c commit a386f62

4 files changed

Lines changed: 26 additions & 27 deletions

File tree

resend/async_request.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,18 @@ async def make_request(self, url: str) -> Union[Dict[str, Any], List[Any]]:
101101
suggested_action="Run: pip install resend[async]",
102102
)
103103

104-
content, _status_code, resp_headers = await async_client.request(
105-
method=self.verb,
106-
url=url,
107-
headers=headers,
108-
json=json_params,
109-
files=self.files,
110-
data=self.data,
111-
)
104+
kwargs: Dict[str, Any] = {
105+
"method": self.verb,
106+
"url": url,
107+
"headers": headers,
108+
"json": json_params,
109+
}
110+
if self.files is not None:
111+
kwargs["files"] = self.files
112+
if self.data is not None:
113+
kwargs["data"] = self.data
114+
115+
content, _status_code, resp_headers = await async_client.request(**kwargs)
112116

113117
# Safety net around the HTTP Client
114118
except ResendError:

resend/contacts/imports/_contact_import.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Optional
1+
from typing_extensions import NotRequired
22

33
from resend._base_response import BaseResponse
44

@@ -38,4 +38,4 @@ class ContactImport(BaseResponse):
3838
id: str
3939
status: str
4040
created_at: str
41-
counts: Optional[ContactImportCounts]
41+
counts: NotRequired[ContactImportCounts]

resend/contacts/imports/_contact_imports.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,6 @@ def list(cls, params: Optional[ListParams] = None) -> ListContactImportsResponse
166166
"""
167167
query_params = cast(Dict[Any, Any], params) if params else None
168168
path = PaginationHelper.build_paginated_path("/contacts/imports", query_params)
169-
# Append status filter if provided (PaginationHelper only handles limit/after/before)
170-
if params and "status" in params:
171-
separator = "&" if "?" in path else "?"
172-
path = f"{path}{separator}status={params['status']}"
173-
174169
resp = request.Request[ContactImports.ListContactImportsResponse](
175170
path=path,
176171
params={},
@@ -254,10 +249,6 @@ async def list_async(cls, params: Optional[ListParams] = None) -> ListContactImp
254249
"""
255250
query_params = cast(Dict[Any, Any], params) if params else None
256251
path = PaginationHelper.build_paginated_path("/contacts/imports", query_params)
257-
if params and "status" in params:
258-
separator = "&" if "?" in path else "?"
259-
path = f"{path}{separator}status={params['status']}"
260-
261252
resp = await AsyncRequest[ContactImports.ListContactImportsResponse](
262253
path=path,
263254
params={},

resend/request.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,18 @@ def make_request(self, url: str) -> Union[Dict[str, Any], List[Any]]:
8888

8989
sync_client = cast(HTTPClient, resend.default_http_client)
9090

91-
content, _status_code, resp_headers = sync_client.request(
92-
method=self.verb,
93-
url=url,
94-
headers=headers,
95-
json=json_params,
96-
files=self.files,
97-
data=self.data,
98-
)
91+
kwargs: Dict[str, Any] = {
92+
"method": self.verb,
93+
"url": url,
94+
"headers": headers,
95+
"json": json_params,
96+
}
97+
if self.files is not None:
98+
kwargs["files"] = self.files
99+
if self.data is not None:
100+
kwargs["data"] = self.data
101+
102+
content, _status_code, resp_headers = sync_client.request(**kwargs)
99103

100104
# Safety net around the HTTP Client
101105
except Exception as e:

0 commit comments

Comments
 (0)