From 94f12235017ae5fc4ed9b6aac9e8d35707909599 Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Sat, 10 Dec 2022 00:10:31 +0530 Subject: [PATCH 1/3] added 'TimestampSeries' in TimedeltaSeries in series.pyi --- pandas-stubs/core/series.pyi | 6 ++++-- tests/test_timefuncs.py | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pandas-stubs/core/series.pyi b/pandas-stubs/core/series.pyi index 280822b57..0aa7c2063 100644 --- a/pandas-stubs/core/series.pyi +++ b/pandas-stubs/core/series.pyi @@ -1773,10 +1773,12 @@ class TimedeltaSeries(Series[Timedelta]): @overload # type: ignore[override] def __add__(self, other: Period) -> PeriodSeries: ... @overload - def __add__(self, other: Timestamp | DatetimeIndex) -> TimestampSeries: ... + def __add__( + self, other: Timestamp | TimestampSeries | DatetimeIndex + ) -> TimestampSeries: ... @overload def __add__(self, other: Timedelta | np.timedelta64) -> TimedeltaSeries: ... - def __radd__(self, pther: Timestamp | TimestampSeries) -> TimestampSeries: ... # type: ignore[override] + def __radd__(self, other: Timestamp | TimestampSeries) -> TimestampSeries: ... # type: ignore[override] @overload # type: ignore[override] def __mul__( self, other: TimestampSeries | np.timedelta64 | Timedelta | TimedeltaSeries diff --git a/tests/test_timefuncs.py b/tests/test_timefuncs.py index b97369466..acfddf29b 100644 --- a/tests/test_timefuncs.py +++ b/tests/test_timefuncs.py @@ -1054,3 +1054,10 @@ def test_timedelta64_and_arithmatic_operator() -> None: assert_type((s1 * td), Never) # pyright: ignore assert_type((s1 / td), Never) # pyright: ignore assert_type((s3 * td), Never) # pyright: ignore + + +def test_add_and_timestampseries() -> None: + tds = pd.Series(pd.timedelta_range(start="1 day", periods=10)) + tss = pd.Series(pd.date_range(start="2012-01-01", periods=10, freq="W-MON")) + plus = tds + tss + check(assert_type(plus, "TimestampSeries"), pd.Series) From 8fa8360cbfeaf3cb76f46d36a19b980b97a3a404 Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Sat, 10 Dec 2022 00:40:09 +0530 Subject: [PATCH 2/3] added 'pd.Timestamp' as last argument to check --- tests/test_timefuncs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_timefuncs.py b/tests/test_timefuncs.py index acfddf29b..24a6091b6 100644 --- a/tests/test_timefuncs.py +++ b/tests/test_timefuncs.py @@ -1056,8 +1056,8 @@ def test_timedelta64_and_arithmatic_operator() -> None: assert_type((s3 * td), Never) # pyright: ignore -def test_add_and_timestampseries() -> None: +def test_timedeltaseries_add_timestampseries() -> None: tds = pd.Series(pd.timedelta_range(start="1 day", periods=10)) tss = pd.Series(pd.date_range(start="2012-01-01", periods=10, freq="W-MON")) plus = tds + tss - check(assert_type(plus, "TimestampSeries"), pd.Series) + check(assert_type(plus, "TimestampSeries"), pd.Series, pd.Timestamp) From d045d52a611ae45b6c48fe421d54d1940ce911bf Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Sun, 11 Dec 2022 22:37:15 +0530 Subject: [PATCH 3/3] changed the black version in pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 20022b5ff..6089d488c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,7 +45,7 @@ pandas = "1.5.2" typing-extensions = ">=4.2.0" matplotlib = ">=3.5.1" pre-commit = ">=2.19.0" -black = ">=22.8.0" +black = ">=22.12.0" isort = ">=5.10.1" openpyxl = ">=3.0.10" tables = { version = ">=3.7.0", python = "<3.11" }