Skip to content

Commit d8abb36

Browse files
committed
Add datetime.date and datetime.datetime specializations
1 parent 237977f commit d8abb36

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pandas-stubs/_libs/tslibs/offsets.pyi

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ from typing import (
1414

1515
from dateutil.relativedelta import weekday as WeekdayClass
1616
import numpy as np
17+
from pandas import Timestamp
1718
from pandas.core.indexes.datetimes import DatetimeIndex
1819
from typing_extensions import Self
1920

@@ -42,6 +43,10 @@ class BaseOffset:
4243
@overload
4344
def __add__(self, other: npt.NDArray[np.object_]) -> npt.NDArray[np.object_]: ...
4445
@overload
46+
def __add__(self, other: date) -> Timestamp: ...
47+
@overload
48+
def __add__(self, other: datetime) -> Timestamp: ...
49+
@overload
4550
def __add__(self, other: BaseOffset) -> Self: ...
4651
@overload
4752
def __add__(self, other: _DatetimeT) -> _DatetimeT: ...
@@ -50,15 +55,28 @@ class BaseOffset:
5055
@overload
5156
def __radd__(self, other: npt.NDArray[np.object_]) -> npt.NDArray[np.object_]: ...
5257
@overload
58+
def __radd__(self, other: date) -> Timestamp: ...
59+
@overload
60+
def __radd__(self, other: datetime) -> Timestamp: ...
61+
@overload
5362
def __radd__(self, other: BaseOffset) -> Self: ...
5463
@overload
5564
def __radd__(self, other: _DatetimeT) -> _DatetimeT: ...
5665
@overload
5766
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
5872
def __sub__(self, other: BaseOffset) -> Self: ...
5973
@overload
6074
def __rsub__(self, other: npt.NDArray[np.object_]) -> npt.NDArray[np.object_]: ...
6175
@overload
76+
def __rsub__(self, other: date) -> Timestamp: ...
77+
@overload
78+
def __rsub__(self, other: datetime) -> Timestamp: ...
79+
@overload
6280
def __rsub__(self, other: BaseOffset) -> Self: ...
6381
@overload
6482
def __rsub__(self, other: _DatetimeT) -> _DatetimeT: ...

0 commit comments

Comments
 (0)