Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions pandas-stubs/core/base.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from collections.abc import (
Hashable,
Iterator,
Sequence,
)
Expand All @@ -11,7 +10,6 @@ from typing import (
Protocol,
TypeAlias,
TypeVar,
final,
overload,
type_check_only,
)
Expand Down Expand Up @@ -42,7 +40,6 @@ from pandas._typing import (
GenericT_co,
Just,
ListLike,
NDFrameT,
Scalar,
SupportsDType,
np_1darray,
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions pandas-stubs/core/groupby/groupby.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pandas-stubs/core/window/rolling.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ from collections.abc import (
import datetime as dt
from typing import (
Any,
Generic,
overload,
)

Expand All @@ -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

Expand All @@ -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
Expand Down
4 changes: 0 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
18 changes: 0 additions & 18 deletions tests/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 2 additions & 10 deletions tests/test_resampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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)

Expand All @@ -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)
Expand Down