diff --git a/pandas-stubs/core/base.pyi b/pandas-stubs/core/base.pyi index e4b820d79..fa60a08cf 100644 --- a/pandas-stubs/core/base.pyi +++ b/pandas-stubs/core/base.pyi @@ -1,5 +1,4 @@ from collections.abc import ( - Hashable, Iterator, Sequence, ) @@ -11,7 +10,6 @@ from typing import ( Protocol, TypeAlias, TypeVar, - final, overload, type_check_only, ) @@ -42,7 +40,6 @@ from pandas._typing import ( GenericT_co, Just, ListLike, - NDFrameT, Scalar, SupportsDType, np_1darray, @@ -54,22 +51,12 @@ from pandas._typing import ( np_ndarray_float, np_ndarray_td, ) -from pandas.util._decorators import cache_readonly T_INTERVAL_NP = TypeVar("T_INTERVAL_NP", bound=np.bytes_ | np.str_) class NoNewAttributesMixin: def __setattr__(self, key: str, value: Any) -> None: ... -class SelectionMixin(Generic[NDFrameT]): - obj: NDFrameT - exclusions: frozenset[Hashable] - @final - @cache_readonly - def ndim(self) -> int: ... - def __getitem__(self, key): ... - def aggregate(self, func, *args: Any, **kwargs: Any): ... - class IndexOpsMixin(OpsMixin, Generic[S1, GenericT_co]): __array_priority__: int = ... @property diff --git a/pandas-stubs/core/groupby/groupby.pyi b/pandas-stubs/core/groupby/groupby.pyi index d0168198e..28cc5d6d2 100644 --- a/pandas-stubs/core/groupby/groupby.pyi +++ b/pandas-stubs/core/groupby/groupby.pyi @@ -18,7 +18,6 @@ from typing import ( ) import numpy as np -from pandas.core.base import SelectionMixin from pandas.core.frame import DataFrame from pandas.core.groupby import generic from pandas.core.groupby.indexing import ( @@ -350,7 +349,7 @@ class GroupByPlot(PlotAccessor, Generic[_GroupByT]): # def __call__(self, *args: Any, **kwargs: Any): ... # def __getattr__(self, name: str): ... -class BaseGroupBy(SelectionMixin[NDFrameT], GroupByIndexingMixin): +class BaseGroupBy(GroupByIndexingMixin, Generic[NDFrameT]): @final def __len__(self) -> int: ... @final diff --git a/pandas-stubs/core/window/rolling.pyi b/pandas-stubs/core/window/rolling.pyi index d48863b77..9be922b48 100644 --- a/pandas-stubs/core/window/rolling.pyi +++ b/pandas-stubs/core/window/rolling.pyi @@ -7,6 +7,7 @@ from collections.abc import ( import datetime as dt from typing import ( Any, + Generic, overload, ) @@ -15,7 +16,6 @@ from pandas import ( Index, Series, ) -from pandas.core.base import SelectionMixin from pandas.core.indexers import BaseIndexer from typing_extensions import Self @@ -34,7 +34,7 @@ from pandas._typing import ( WindowingRankType, ) -class BaseWindow(SelectionMixin[NDFrameT]): +class BaseWindow(Generic[NDFrameT]): on: str | Index | None closed: IntervalClosedType | None step: int | None diff --git a/pyproject.toml b/pyproject.toml index 540bb7117..caa588132 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -217,10 +217,6 @@ ignore = [ # TODO: remove when array is fully typed "ANN001", "ANN201", "ANN204", "ANN206", ] -"*core/base.pyi" = [ - # TODO: remove when core/base.pyi is fully typed - "ANN001", "ANN201", "ANN204", "ANN206", -] "*excel/_base.pyi" = [ # TODO: remove when excel/_base.pyi is fully typed "ANN001", "ANN201", "ANN204", "ANN206", diff --git a/tests/__init__.py b/tests/__init__.py index f11a46a34..ca2525692 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -139,7 +139,7 @@ def check( elif isinstance(actual, pd.Index): value = actual[index_to_check_for_type] elif isinstance(actual, BaseGroupBy): - value = actual.obj + value = actual.obj # type: ignore[attr-defined] # pyright: ignore[reportAttributeAccessIssue] elif hasattr(actual, "__iter__"): value = next( iter(actual) # pyright: ignore[reportArgumentType,reportCallIssue] diff --git a/tests/test_groupby.py b/tests/test_groupby.py index b0287217b..2e9699b5f 100644 --- a/tests/test_groupby.py +++ b/tests/test_groupby.py @@ -70,9 +70,6 @@ def test_frame_groupby_resample() -> None: DataFrame, ) - # props - check(assert_type(GB_DF.resample("ME").obj, DataFrame), DataFrame) - # agg funcs with pytest_warns_bounded( FutureWarning, @@ -312,9 +309,6 @@ def test_series_groupby_resample() -> None: Series, ) - # props - check(assert_type(GB_S.resample("ME").obj, "Series[float]"), Series, float) - # agg funcs check(assert_type(GB_S.resample("ME").sum(), "Series[float]"), Series, float) check(assert_type(GB_S.resample("ME").prod(), "Series[float]"), Series, float) @@ -471,7 +465,6 @@ def test_frame_groupby_rolling() -> None: ) # props - check(assert_type(GB_DF.rolling(1).obj, DataFrame), DataFrame) check(assert_type(GB_DF.rolling(1).on, str | Index | None), type(None)) check(assert_type(GB_DF.rolling(1).method, Literal["single", "table"]), str) if PD_LTE_23: @@ -596,9 +589,6 @@ def test_series_groupby_rolling() -> None: Series, ) - # props - check(assert_type(GB_S.rolling(1).obj, "Series[float]"), Series, float) - # agg funcs check(assert_type(GB_S.rolling(1).sum(), "Series[float]"), Series, float) check(assert_type(GB_S.rolling(1).min(), "Series[float]"), Series, float) @@ -666,7 +656,6 @@ def test_frame_groupby_expanding() -> None: ) # props - check(assert_type(GB_DF.expanding(1).obj, DataFrame), DataFrame) check(assert_type(GB_DF.expanding(1).on, str | Index | None), type(None)) check(assert_type(GB_DF.expanding(1).method, Literal["single", "table"]), str) if PD_LTE_23: @@ -795,9 +784,6 @@ def test_series_groupby_expanding() -> None: Series, ) - # props - check(assert_type(GB_S.expanding(1).obj, "Series[float]"), Series, float) - # agg funcs check(assert_type(GB_S.expanding(1).sum(), "Series[float]"), Series, float) check(assert_type(GB_S.expanding(1).min(), "Series[float]"), Series, float) @@ -865,7 +851,6 @@ def test_frame_groupby_ewm() -> None: ) # props - check(assert_type(GB_DF.ewm(1).obj, DataFrame), DataFrame) check(assert_type(GB_DF.ewm(1).on, str | Index | None), type(None)) check(assert_type(GB_DF.ewm(1).method, Literal["single", "table"]), str) if PD_LTE_23: @@ -973,9 +958,6 @@ def test_series_groupby_ewm() -> None: Series, ) - # props - check(assert_type(GB_S.ewm(1).obj, "Series[float]"), Series, float) - # agg funcs check(assert_type(GB_S.ewm(1).sum(), "Series[float]"), Series, float) check(assert_type(GB_S.ewm(1).mean(), "Series[float]"), Series, float) diff --git a/tests/test_resampler.py b/tests/test_resampler.py index f9da71ebe..8f60cb45d 100644 --- a/tests/test_resampler.py +++ b/tests/test_resampler.py @@ -40,10 +40,6 @@ _AggRetType = DataFrame | Series -def test_props() -> None: - check(assert_type(DF.resample("ME").obj, DataFrame), DataFrame) - - def test_iter() -> None: assert_type(iter(DF.resample("ME")), Iterator[tuple[Hashable, DataFrame]]) for v in DF.resample("ME"): @@ -203,7 +199,7 @@ def j( kw: tuple[int], ) -> DataFrame: assert isinstance(res, DatetimeIndexResampler) - return res.obj + return DataFrame({"a": [1, 2, 3]}) check( assert_type(DF.resample("ME").pipe(j, 1, [1.0], arg2="hi", kw=(1,)), DataFrame), @@ -263,7 +259,7 @@ def j( def k(x: int, t: "DatetimeIndexResampler[DataFrame]") -> DataFrame: assert isinstance(x, int) - return t.obj + return DataFrame({"a": [1, 2, 3]}) check(assert_type(DF.resample("ME").pipe((k, "t"), 1), DataFrame), DataFrame) @@ -281,10 +277,6 @@ def f(val: Series) -> Series: check(assert_type(DF.resample("ME").transform(f), DataFrame), DataFrame) -def test_props_series() -> None: - check(assert_type(S.resample("ME").obj, Series), Series) - - def test_iter_series() -> None: for v in S.resample("ME"): check(assert_type(v, tuple[Hashable, Series]), tuple)