Skip to content

Commit e39fa2f

Browse files
more precise NaT stub
1 parent 5126dca commit e39fa2f

File tree

1 file changed

+18
-21
lines changed

1 file changed

+18
-21
lines changed

pandas/_libs/tslibs/nattype.pyi

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,9 @@ NaT: NaTType
2525
iNaT: int
2626
nat_strings: set[str]
2727

28-
_NaTComparisonTypes: TypeAlias = (
29-
datetime | timedelta | Period | np.datetime64 | np.timedelta64
30-
)
28+
_TimeLike: TypeAlias = datetime | timedelta | Period | np.datetime64 | np.timedelta64
29+
_TimeDelta: TypeAlias = timedelta | np.timedelta64
3130

32-
class _NatComparison:
33-
def __call__(self, other: _NaTComparisonTypes) -> bool: ...
3431

3532
class NaTType:
3633
_value: np.int64
@@ -161,30 +158,30 @@ class NaTType:
161158
@property
162159
def qyear(self) -> float: ...
163160
# comparisons
164-
def __eq__(self, other: object) -> bool: ...
165-
def __ne__(self, other: object) -> bool: ...
166-
__lt__: _NatComparison
167-
__le__: _NatComparison
168-
__gt__: _NatComparison
169-
__ge__: _NatComparison
161+
def __eq__(self, other: object, /) -> bool: ...
162+
def __ne__(self, other: object, /) -> bool: ...
163+
def __lt__(self, other: Self | _TimeLike, /) -> Literal[False]: ...
164+
def __le__(self, other: Self | _TimeLike, /) -> Literal[False]: ...
165+
def __gt__(self, other: Self | _TimeLike, /) -> Literal[False]: ...
166+
def __ge__(self, other: Self | _TimeLike, /) -> Literal[False]: ...
170167
# unary operators
171168
def __pos__(self) -> Self: ...
172169
def __neg__(self) -> Self: ...
173170
# binary operators
174-
def __sub__(self, other: Self | timedelta | datetime) -> Self: ...
175-
def __rsub__(self, other: Self | timedelta | datetime) -> Self: ...
176-
def __add__(self, other: Self | timedelta | datetime) -> Self: ...
177-
def __radd__(self, other: Self | timedelta | datetime) -> Self: ...
178-
def __mul__(self, other: float) -> Self: ... # analogous to timedelta
179-
def __rmul__(self, other: float) -> Self: ...
171+
def __sub__(self, other: Self | _TimeLike, /) -> Self: ...
172+
def __rsub__(self, other: Self | _TimeLike, /) -> Self: ...
173+
def __add__(self, other: Self | _TimeLike, /) -> Self: ...
174+
def __radd__(self, other: Self | _TimeLike, /) -> Self: ...
175+
def __mul__(self, other: float, /) -> Self: ... # analogous to timedelta
176+
def __rmul__(self, other: float, /) -> Self: ...
180177
@overload # analogous to timedelta
181-
def __truediv__(self, other: Self | timedelta) -> float: ... # Literal[NaN]
178+
def __truediv__(self, other: Self | _TimeDelta, /) -> float: ... # Literal[NaN]
182179
@overload
183-
def __truediv__(self, other: float) -> Self: ...
180+
def __truediv__(self, other: float, /) -> Self: ...
184181
@overload # analogous to timedelta
185-
def __floordiv__(self, other: Self | timedelta) -> float: ... # Literal[NaN]
182+
def __floordiv__(self, other: Self | _TimeDelta, /) -> float: ... # Literal[NaN]
186183
@overload
187-
def __floordiv__(self, other: float) -> Self: ...
184+
def __floordiv__(self, other: float, /) -> Self: ...
188185
# other
189186
def __hash__(self) -> int: ...
190187
def as_unit(self, unit: str, round_ok: bool = ...) -> NaTType: ...

0 commit comments

Comments
 (0)