Skip to content

Commit 39b3b98

Browse files
committed
remove NaTType as possible result of Timestamp and Timedelta constructor
1 parent 1cc352a commit 39b3b98

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

pandas/_libs/tslibs/timedeltas.pyi

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,12 @@ class Timedelta(timedelta):
3333
max: ClassVar[Timedelta]
3434
resolution: ClassVar[Timedelta]
3535
value: int # np.int64
36-
37-
# error: "__new__" must return a class instance (got "Union[Timedelta, NaTType]")
38-
def __new__( # type: ignore[misc]
36+
def __new__(
3937
cls: Type[_S],
4038
value=...,
4139
unit: str = ...,
4240
**kwargs: int | float | np.integer | np.floating,
43-
) -> _S | NaTType: ...
41+
) -> _S: ...
4442
@property
4543
def days(self) -> int: ...
4644
@property

pandas/_libs/tslibs/timestamps.pyi

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ class Timestamp(datetime):
3131

3232
resolution: ClassVar[Timedelta]
3333
value: int # np.int64
34-
35-
# error: "__new__" must return a class instance (got "Union[Timestamp, NaTType]")
36-
def __new__( # type: ignore[misc]
34+
def __new__(
3735
cls: type[_DatetimeT],
3836
ts_input: int
3937
| np.integer
@@ -56,7 +54,7 @@ class Timestamp(datetime):
5654
tzinfo: _tzinfo | None = ...,
5755
*,
5856
fold: int | None = ...,
59-
) -> _DatetimeT | NaTType: ...
57+
) -> _DatetimeT: ...
6058
def _set_freq(self, freq: BaseOffset | None) -> None: ...
6159
@property
6260
def year(self) -> int: ...

0 commit comments

Comments
 (0)