Skip to content

Commit 7a4bee7

Browse files
committed
Add tests and update overload order
1 parent d8abb36 commit 7a4bee7

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

pandas-stubs/_libs/tslibs/offsets.pyi

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ class BaseOffset:
4545
@overload
4646
def __add__(self, other: date) -> Timestamp: ...
4747
@overload
48-
def __add__(self, other: datetime) -> Timestamp: ...
49-
@overload
5048
def __add__(self, other: BaseOffset) -> Self: ...
5149
@overload
5250
def __add__(self, other: _DatetimeT) -> _DatetimeT: ...
@@ -57,26 +55,15 @@ class BaseOffset:
5755
@overload
5856
def __radd__(self, other: date) -> Timestamp: ...
5957
@overload
60-
def __radd__(self, other: datetime) -> Timestamp: ...
61-
@overload
6258
def __radd__(self, other: BaseOffset) -> Self: ...
6359
@overload
6460
def __radd__(self, other: _DatetimeT) -> _DatetimeT: ...
6561
@overload
6662
def __radd__(self, other: _TimedeltaT) -> _TimedeltaT: ...
67-
@overload
68-
def __sub__(self, other: date) -> Timestamp: ...
69-
@overload
70-
def __sub__(self, other: datetime) -> Timestamp: ...
71-
@overload
72-
def __sub__(self, other: BaseOffset) -> Self: ...
73-
@overload
7463
def __rsub__(self, other: npt.NDArray[np.object_]) -> npt.NDArray[np.object_]: ...
7564
@overload
7665
def __rsub__(self, other: date) -> Timestamp: ...
7766
@overload
78-
def __rsub__(self, other: datetime) -> Timestamp: ...
79-
@overload
8067
def __rsub__(self, other: BaseOffset) -> Self: ...
8168
@overload
8269
def __rsub__(self, other: _DatetimeT) -> _DatetimeT: ...

tests/test_timefuncs.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -664,8 +664,10 @@ def test_some_offsets() -> None:
664664
),
665665
pd.DatetimeIndex,
666666
)
667-
# GH 224
668-
check(assert_type(dt.date.today() - Day(), dt.date), dt.date)
667+
# GH 755
668+
check(assert_type(dt.date.today() - Day(), pd.Timestamp), pd.Timestamp)
669+
check(assert_type(dt.date.today() + Day(), pd.Timestamp), pd.Timestamp)
670+
check(assert_type(Day() + dt.date.today(), pd.Timestamp), pd.Timestamp)
669671
# GH 235
670672
check(
671673
assert_type(

0 commit comments

Comments
 (0)