Skip to content

Commit f25efba

Browse files
authored
Add tests and update overload order
1 parent 9accf9a commit f25efba

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
@@ -44,8 +44,6 @@ class BaseOffset:
4444
@overload
4545
def __add__(self, other: date) -> Timestamp: ...
4646
@overload
47-
def __add__(self, other: datetime) -> Timestamp: ...
48-
@overload
4947
def __add__(self, other: BaseOffset) -> Self: ...
5048
@overload
5149
def __add__(self, other: _DatetimeT) -> _DatetimeT: ...
@@ -56,26 +54,15 @@ class BaseOffset:
5654
@overload
5755
def __radd__(self, other: date) -> Timestamp: ...
5856
@overload
59-
def __radd__(self, other: datetime) -> Timestamp: ...
60-
@overload
6157
def __radd__(self, other: BaseOffset) -> Self: ...
6258
@overload
6359
def __radd__(self, other: _DatetimeT) -> _DatetimeT: ...
6460
@overload
6561
def __radd__(self, other: _TimedeltaT) -> _TimedeltaT: ...
66-
@overload
67-
def __sub__(self, other: date) -> Timestamp: ...
68-
@overload
69-
def __sub__(self, other: datetime) -> Timestamp: ...
70-
@overload
71-
def __sub__(self, other: BaseOffset) -> Self: ...
72-
@overload
7362
def __rsub__(self, other: npt.NDArray[np.object_]) -> npt.NDArray[np.object_]: ...
7463
@overload
7564
def __rsub__(self, other: date) -> Timestamp: ...
7665
@overload
77-
def __rsub__(self, other: datetime) -> Timestamp: ...
78-
@overload
7966
def __rsub__(self, other: BaseOffset) -> Self: ...
8067
@overload
8168
def __rsub__(self, other: _DatetimeT) -> _DatetimeT: ...

tests/test_timefuncs.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,8 +655,10 @@ def test_some_offsets() -> None:
655655
),
656656
pd.DatetimeIndex,
657657
)
658-
# GH 224
659-
check(assert_type(dt.date.today() - Day(), dt.date), dt.date)
658+
# GH 755
659+
check(assert_type(dt.date.today() - Day(), pd.Timestamp), pd.Timestamp)
660+
check(assert_type(dt.date.today() + Day(), pd.Timestamp), pd.Timestamp)
661+
check(assert_type(Day() + dt.date.today(), pd.Timestamp), pd.Timestamp)
660662
# GH 235
661663
check(
662664
assert_type(

0 commit comments

Comments
 (0)