Skip to content

Commit d929969

Browse files
jorenhamcharris
authored andcommitted
TYP: timedelta64: datetime.timedelta construction isn't deprecated (#32942)
1 parent 839467f commit d929969

2 files changed

Lines changed: 3 additions & 7 deletions

File tree

‎numpy/__init__.pyi‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6891,6 +6891,8 @@ class timedelta64(_IntegralMixin, generic[_TD64ItemT_co], Generic[_TD64ItemT_co]
68916891
@overload
68926892
def __new__(cls, value: timedelta64[_TD64ItemT_co], /) -> Self: ...
68936893
@overload
6894+
def __new__(cls, value: dt.timedelta, /) -> timedelta64[dt.timedelta]: ...
6895+
@overload
68946896
@deprecated(
68956897
"Using 'generic' unit for NumPy timedelta is deprecated, and will raise an error in the future. "
68966898
"Please use a specific units instead."
@@ -6923,12 +6925,6 @@ class timedelta64(_IntegralMixin, generic[_TD64ItemT_co], Generic[_TD64ItemT_co]
69236925
@overload
69246926
def __new__(cls, value: dt.timedelta, format: _TimeUnitSpec[_IntTimeUnit], /) -> timedelta64[int]: ...
69256927
@overload
6926-
@deprecated(
6927-
"Using 'generic' unit for NumPy timedelta is deprecated, and will raise an error in the future. "
6928-
"Please use a specific units instead."
6929-
)
6930-
def __new__(cls, value: dt.timedelta | _IntLike_co, /) -> timedelta64[dt.timedelta]: ...
6931-
@overload
69326928
def __new__(
69336929
cls,
69346930
value: dt.timedelta | _IntLike_co,

‎numpy/typing/tests/data/pass/scalars.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def __float__(self) -> float:
113113
np.timedelta64("3") # type: ignore[deprecated]
114114
np.timedelta64(b"5") # type: ignore[deprecated]
115115
np.timedelta64(np.timedelta64(2)) # type: ignore[deprecated]
116-
np.timedelta64(dt.timedelta(2)) # type: ignore[deprecated]
116+
np.timedelta64(dt.timedelta(2))
117117
np.timedelta64(None) # type: ignore[deprecated]
118118
np.timedelta64(None, "D")
119119

0 commit comments

Comments
 (0)