Skip to content

Commit e3673c0

Browse files
committed
MOD: Fix get_dataset_condition
1 parent ce24b32 commit e3673c0

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 0.57.0 - TBD
4+
5+
#### Deprecations
6+
- Deprecated `int` and `pd.Timestamp` types for `start_date` and `end_date` parameters which will be removed in v0.59.0
7+
38
## 0.56.0 - 2025-06-03
49

510
#### Breaking changes

databento/common/parsing.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import warnings
34
from collections.abc import Iterable
45
from datetime import date
56
from datetime import datetime
@@ -220,7 +221,7 @@ def optional_date_to_string(value: date | str | None) -> str | None:
220221
if value is None:
221222
return None
222223

223-
return datetime_to_date_string(value)
224+
return date_to_string(value)
224225

225226

226227
def datetime_to_string(value: pd.Timestamp | datetime | date | str | int) -> str:
@@ -249,7 +250,7 @@ def datetime_to_string(value: pd.Timestamp | datetime | date | str | int) -> str
249250
return pd.to_datetime(value).isoformat()
250251

251252

252-
def datetime_to_date_string(value: pd.Timestamp | date | str | int) -> str:
253+
def date_to_string(value: pd.Timestamp | date | str | int) -> str:
253254
"""
254255
Return a valid date string from the given value.
255256
@@ -265,11 +266,31 @@ def datetime_to_date_string(value: pd.Timestamp | date | str | int) -> str:
265266
"""
266267
if isinstance(value, str):
267268
return value
268-
elif isinstance(value, int):
269-
return str(value)
270269
elif isinstance(value, date):
271270
return value.isoformat()
271+
elif isinstance(value, int):
272+
warnings.warn(
273+
"Passing an int to `start_date` or `end_date` is deprecated and will be removed in v0.59.0."
274+
"Use a date or str instead.",
275+
DeprecationWarning,
276+
stacklevel=2,
277+
)
278+
return str(value)
279+
elif isinstance(value, pd.Timestamp):
280+
warnings.warn(
281+
"Passing a pandas Timestamp to `start_date` or `end_date` is deprecated and will be removed in v0.59.0."
282+
"Use a date or str instead.",
283+
DeprecationWarning,
284+
stacklevel=2,
285+
)
286+
return pd.to_datetime(value).date().isoformat()
272287
else:
288+
warnings.warn(
289+
f"Passing a {type(value)} to `start_date` or `end_date` is deprecated and will be removed in v0.59.0."
290+
"Use a date or str instead.",
291+
DeprecationWarning,
292+
stacklevel=2,
293+
)
273294
return pd.to_datetime(value).date().isoformat()
274295

275296

databento/historical/api/symbology.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from databento.common import API_VERSION
1111
from databento.common.http import BentoHttpAPI
12-
from databento.common.parsing import datetime_to_date_string
12+
from databento.common.parsing import date_to_string
1313
from databento.common.parsing import optional_date_to_string
1414
from databento.common.parsing import optional_symbols_list_to_list
1515
from databento.common.publishers import Dataset
@@ -69,7 +69,7 @@ def resolve(
6969
"symbols": ",".join(symbols_list),
7070
"stype_in": str(stype_in_valid),
7171
"stype_out": str(validate_enum(stype_out, SType, "stype_out")),
72-
"start_date": datetime_to_date_string(start_date),
72+
"start_date": date_to_string(start_date),
7373
"end_date": optional_date_to_string(end_date),
7474
}
7575

0 commit comments

Comments
 (0)