From 477cb2ac2188c6782952cc7903d5c33aecc3888f Mon Sep 17 00:00:00 2001 From: cmp0xff Date: Thu, 3 Apr 2025 13:18:22 +0200 Subject: [PATCH 1/3] fix: Series.dt argument 'ambiguous' --- pandas-stubs/core/indexes/accessors.pyi | 6 +++--- tests/test_timefuncs.py | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/pandas-stubs/core/indexes/accessors.pyi b/pandas-stubs/core/indexes/accessors.pyi index 1ce5dfdbc..735da79f9 100644 --- a/pandas-stubs/core/indexes/accessors.pyi +++ b/pandas-stubs/core/indexes/accessors.pyi @@ -167,7 +167,7 @@ class _DatetimeRoundingMethods(Generic[_DTTimestampTimedeltaReturnType]): def round( self, freq: str | BaseOffset | None, - ambiguous: Literal["raise", "infer", "NaT"] | np_ndarray_bool = ..., + ambiguous: Literal["raise", "infer", "NaT"] | bool | np_ndarray_bool = ..., nonexistent: ( Literal["shift_forward", "shift_backward", "NaT", "raise"] | timedelta @@ -177,7 +177,7 @@ class _DatetimeRoundingMethods(Generic[_DTTimestampTimedeltaReturnType]): def floor( self, freq: str | BaseOffset | None, - ambiguous: Literal["raise", "infer", "NaT"] | np_ndarray_bool = ..., + ambiguous: Literal["raise", "infer", "NaT"] | bool | np_ndarray_bool = ..., nonexistent: ( Literal["shift_forward", "shift_backward", "NaT", "raise"] | timedelta @@ -187,7 +187,7 @@ class _DatetimeRoundingMethods(Generic[_DTTimestampTimedeltaReturnType]): def ceil( self, freq: str | BaseOffset | None, - ambiguous: Literal["raise", "infer", "NaT"] | np_ndarray_bool = ..., + ambiguous: Literal["raise", "infer", "NaT"] | bool | np_ndarray_bool = ..., nonexistent: ( Literal["shift_forward", "shift_backward", "NaT", "raise"] | timedelta diff --git a/tests/test_timefuncs.py b/tests/test_timefuncs.py index e8d2e4773..40ee32959 100644 --- a/tests/test_timefuncs.py +++ b/tests/test_timefuncs.py @@ -489,16 +489,31 @@ def test_series_dt_accessors() -> None: pd.Series, pd.Timestamp, ) + check( + assert_type(s0.dt.round("D", ambiguous=False), "TimestampSeries"), + pd.Series, + pd.Timestamp, + ) check( assert_type(s0.dt.floor("D", nonexistent=dt.timedelta(1)), "TimestampSeries"), pd.Series, pd.Timestamp, ) + check( + assert_type(s0.dt.floor("D", ambiguous=False), "TimestampSeries"), + pd.Series, + pd.Timestamp, + ) check( assert_type(s0.dt.ceil("D", nonexistent=dt.timedelta(1)), "TimestampSeries"), pd.Series, pd.Timestamp, ) + check( + assert_type(s0.dt.ceil("D", ambiguous=False), "TimestampSeries"), + pd.Series, + pd.Timestamp, + ) check(assert_type(s0.dt.month_name(), "pd.Series[str]"), pd.Series, str) check(assert_type(s0.dt.day_name(), "pd.Series[str]"), pd.Series, str) check(assert_type(s0.dt.unit, TimeUnit), str) From 585c942eccc6fd792a7b6900a7b32da47884419a Mon Sep 17 00:00:00 2001 From: cmp0xff Date: Thu, 3 Apr 2025 17:58:56 +0200 Subject: [PATCH 2/3] fix(pyright): https://github.com/pandas-dev/pandas-stubs/pull/1178#issuecomment-2776181445 --- tests/test_io.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_io.py b/tests/test_io.py index cca219c42..0397629ee 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -43,7 +43,6 @@ from pandas._testing import ensure_clean import pytest import sqlalchemy -import sqlalchemy.ext.declarative import sqlalchemy.orm import sqlalchemy.orm.decl_api from typing_extensions import assert_type From 76a5045538910d35303d43f0ec7167d092688a39 Mon Sep 17 00:00:00 2001 From: cmp0xff Date: Thu, 3 Apr 2025 18:35:24 +0200 Subject: [PATCH 3/3] fix(pyright): https://github.com/pandas-dev/pandas-stubs/pull/1178#pullrequestreview-2740521630 https://github.com/microsoft/pyright/issues/10248 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 9b967bf59..c22fd5b6d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,7 @@ mypy = "1.15.0" pandas = "2.2.3" pyarrow = ">=10.0.1" pytest = ">=7.1.2" -pyright = ">=1.1.396" +pyright = ">=1.1.396,!=1.1.398" poethepoet = ">=0.16.5" loguru = ">=0.6.0" typing-extensions = ">=4.4.0"