Skip to content

Commit 52f8ebd

Browse files
authored
gh-460: added 'TimestampSeries' in TimedeltaSeries in series.pyi (#464)
* added 'TimestampSeries' in TimedeltaSeries in series.pyi * added 'pd.Timestamp' as last argument to check * changed the black version in pyproject.toml
1 parent 8abb93a commit 52f8ebd

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

pandas-stubs/core/series.pyi

+4-2
Original file line numberDiff line numberDiff line change
@@ -1773,10 +1773,12 @@ class TimedeltaSeries(Series[Timedelta]):
17731773
@overload # type: ignore[override]
17741774
def __add__(self, other: Period) -> PeriodSeries: ...
17751775
@overload
1776-
def __add__(self, other: Timestamp | DatetimeIndex) -> TimestampSeries: ...
1776+
def __add__(
1777+
self, other: Timestamp | TimestampSeries | DatetimeIndex
1778+
) -> TimestampSeries: ...
17771779
@overload
17781780
def __add__(self, other: Timedelta | np.timedelta64) -> TimedeltaSeries: ...
1779-
def __radd__(self, pther: Timestamp | TimestampSeries) -> TimestampSeries: ... # type: ignore[override]
1781+
def __radd__(self, other: Timestamp | TimestampSeries) -> TimestampSeries: ... # type: ignore[override]
17801782
@overload # type: ignore[override]
17811783
def __mul__(
17821784
self, other: TimestampSeries | np.timedelta64 | Timedelta | TimedeltaSeries

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pandas = "1.5.2"
4545
typing-extensions = ">=4.2.0"
4646
matplotlib = ">=3.5.1"
4747
pre-commit = ">=2.19.0"
48-
black = ">=22.8.0"
48+
black = ">=22.12.0"
4949
isort = ">=5.10.1"
5050
openpyxl = ">=3.0.10"
5151
tables = { version = ">=3.7.0", python = "<3.11" }

tests/test_timefuncs.py

+7
Original file line numberDiff line numberDiff line change
@@ -1054,3 +1054,10 @@ def test_timedelta64_and_arithmatic_operator() -> None:
10541054
assert_type((s1 * td), Never) # pyright: ignore
10551055
assert_type((s1 / td), Never) # pyright: ignore
10561056
assert_type((s3 * td), Never) # pyright: ignore
1057+
1058+
1059+
def test_timedeltaseries_add_timestampseries() -> None:
1060+
tds = pd.Series(pd.timedelta_range(start="1 day", periods=10))
1061+
tss = pd.Series(pd.date_range(start="2012-01-01", periods=10, freq="W-MON"))
1062+
plus = tds + tss
1063+
check(assert_type(plus, "TimestampSeries"), pd.Series, pd.Timestamp)

0 commit comments

Comments
 (0)