Skip to content

Commit 575e7c4

Browse files
committed
fix: from_ and to_date default values
1 parent e6babc9 commit 575e7c4

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

src/linkup/client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def search(
9696
LinkupInsufficientCreditError: If you have run out of credit.
9797
LinkupNoResultError: If the search query did not yield any result.
9898
"""
99-
params: dict[str, Union[str, bool, list[str]]] = self._get_search_params(
99+
params: dict[str, Union[str, bool, list[str], None]] = self._get_search_params(
100100
query=query,
101101
depth=depth,
102102
output_type=output_type,
@@ -172,7 +172,7 @@ async def async_search(
172172
LinkupAuthenticationError: If the Linkup API key is invalid, or there is no more credit
173173
available.
174174
"""
175-
params: dict[str, Union[str, bool, list[str]]] = self._get_search_params(
175+
params: dict[str, Union[str, bool, list[str], None]] = self._get_search_params(
176176
query=query,
177177
depth=depth,
178178
output_type=output_type,
@@ -316,7 +316,7 @@ def _get_search_params(
316316
include_domains: Union[list[str], None],
317317
from_date: Union[date, None],
318318
to_date: Union[date, None],
319-
) -> dict[str, Union[str, bool, list[str]]]:
319+
) -> dict[str, Union[str, bool, list[str], None]]:
320320
structured_output_schema_param: str = ""
321321
if structured_output_schema is not None:
322322
if isinstance(structured_output_schema, str):
@@ -337,8 +337,8 @@ def _get_search_params(
337337
includeImages=include_images,
338338
excludeDomains=exclude_domains or [],
339339
includeDomains=include_domains or [],
340-
fromDate=from_date.isoformat() if from_date is not None else "",
341-
toDate=to_date.isoformat() if to_date is not None else "",
340+
fromDate=from_date.isoformat() if from_date is not None else None,
341+
toDate=to_date.isoformat() if to_date is not None else date.today().isoformat(),
342342
)
343343

344344
def _validate_search_response(

tests/unit/client_test.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ class Company(BaseModel):
4242
"includeImages": False,
4343
"excludeDomains": [],
4444
"includeDomains": [],
45-
"fromDate": "",
46-
"toDate": "",
45+
"fromDate": None,
46+
"toDate": "2000-01-01",
4747
},
4848
b"""
4949
{
@@ -109,8 +109,8 @@ class Company(BaseModel):
109109
"includeImages": False,
110110
"excludeDomains": [],
111111
"includeDomains": [],
112-
"fromDate": "",
113-
"toDate": "",
112+
"fromDate": None,
113+
"toDate": "2000-01-01",
114114
},
115115
b"""
116116
{
@@ -158,8 +158,8 @@ class Company(BaseModel):
158158
"includeImages": False,
159159
"excludeDomains": [],
160160
"includeDomains": [],
161-
"fromDate": "",
162-
"toDate": "",
161+
"fromDate": None,
162+
"toDate": "2000-01-01",
163163
},
164164
b"""
165165
{
@@ -191,8 +191,8 @@ class Company(BaseModel):
191191
"includeImages": False,
192192
"excludeDomains": [],
193193
"includeDomains": [],
194-
"fromDate": "",
195-
"toDate": "",
194+
"fromDate": None,
195+
"toDate": "2000-01-01",
196196
},
197197
b"""
198198
{
@@ -225,6 +225,7 @@ def test_search(
225225
mock_request_response_content: bytes,
226226
expected_search_response: Any,
227227
) -> None:
228+
mocker.patch("linkup.client.date").today.return_value = date(2000, 1, 1)
228229
request_mock = mocker.patch(
229230
"linkup.client.LinkupClient._request",
230231
return_value=Response(
@@ -257,6 +258,7 @@ async def test_async_search(
257258
mock_request_response_content: bytes,
258259
expected_search_response: Any,
259260
) -> None:
261+
mocker.patch("linkup.client.date").today.return_value = date(2000, 1, 1)
260262
request_mock = mocker.patch(
261263
"linkup.client.LinkupClient._async_request",
262264
return_value=Response(

0 commit comments

Comments
 (0)