Skip to content

Commit 9accf9a

Browse files
authored
Add datetime.date and datetime.datetime specializations
1 parent 5177d67 commit 9accf9a

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
@@ -13,6 +13,7 @@ from typing import (
1313
)
1414

1515
import numpy as np
16+
from pandas import Timestamp
1617
from pandas.core.indexes.datetimes import DatetimeIndex
1718
from typing_extensions import Self
1819

@@ -41,6 +42,10 @@ class BaseOffset:
4142
@overload
4243
def __add__(self, other: npt.NDArray[np.object_]) -> npt.NDArray[np.object_]: ...
4344
@overload
45+
def __add__(self, other: date) -> Timestamp: ...
46+
@overload
47+
def __add__(self, other: datetime) -> Timestamp: ...
48+
@overload
4449
def __add__(self, other: BaseOffset) -> Self: ...
4550
@overload
4651
def __add__(self, other: _DatetimeT) -> _DatetimeT: ...
@@ -49,15 +54,28 @@ class BaseOffset:
4954
@overload
5055
def __radd__(self, other: npt.NDArray[np.object_]) -> npt.NDArray[np.object_]: ...
5156
@overload
57+
def __radd__(self, other: date) -> Timestamp: ...
58+
@overload
59+
def __radd__(self, other: datetime) -> Timestamp: ...
60+
@overload
5261
def __radd__(self, other: BaseOffset) -> Self: ...
5362
@overload
5463
def __radd__(self, other: _DatetimeT) -> _DatetimeT: ...
5564
@overload
5665
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
5771
def __sub__(self, other: BaseOffset) -> Self: ...
5872
@overload
5973
def __rsub__(self, other: npt.NDArray[np.object_]) -> npt.NDArray[np.object_]: ...
6074
@overload
75+
def __rsub__(self, other: date) -> Timestamp: ...
76+
@overload
77+
def __rsub__(self, other: datetime) -> Timestamp: ...
78+
@overload
6179
def __rsub__(self, other: BaseOffset) -> Self: ...
6280
@overload
6381
def __rsub__(self, other: _DatetimeT) -> _DatetimeT: ...

0 commit comments

Comments
 (0)