Skip to content

GHXXX Clean up from stubtest #1267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 30, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 0 additions & 4 deletions pandas-stubs/core/frame.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1990,15 +1990,13 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
self,
axis: Axis | None = ...,
skipna: _bool | None = ...,
level: None = ...,
numeric_only: _bool = ...,
**kwargs: Any,
) -> Series: ...
def kurtosis(
self,
axis: Axis | None = ...,
skipna: _bool | None = ...,
level: None = ...,
numeric_only: _bool = ...,
**kwargs: Any,
) -> Series: ...
Expand Down Expand Up @@ -2042,15 +2040,13 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
self,
axis: Axis | None = ...,
skipna: _bool | None = ...,
level: None = ...,
numeric_only: _bool = ...,
**kwargs: Any,
) -> Series: ...
def mean(
self,
axis: Axis | None = ...,
skipna: _bool | None = ...,
level: None = ...,
numeric_only: _bool = ...,
**kwargs: Any,
) -> Series: ...
Expand Down
25 changes: 16 additions & 9 deletions pandas-stubs/core/indexes/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ from pandas._typing import (
DropKeep,
DtypeArg,
DtypeObj,
FillnaOptions,
HashableT,
Label,
Level,
Expand Down Expand Up @@ -313,7 +312,13 @@ class Index(IndexOpsMixin[S1]):
def rename(self, name, inplace: Literal[True]) -> None: ...
@property
def nlevels(self) -> int: ...
def sortlevel(self, level=..., ascending: bool = ..., sort_remaining=...): ...
def sortlevel(
self,
level=...,
ascending: bool = ...,
sort_remaining=...,
na_position: Literal["first", "last"] = ...,
): ...
def get_level_values(self, level: int | _str) -> Index: ...
def droplevel(self, level: Level | list[Level] = ...): ...
@property
Expand Down Expand Up @@ -353,12 +358,7 @@ class Index(IndexOpsMixin[S1]):
def symmetric_difference(
self, other: list[S1] | Self, result_name: Hashable = ..., sort=...
) -> Self: ...
def get_loc(
self,
key: Label,
method: FillnaOptions | Literal["nearest"] | None = ...,
tolerance=...,
) -> int | slice | np_ndarray_bool: ...
def get_loc(self, key: Label) -> int | slice | np_ndarray_bool: ...
def get_indexer(
self, target, method: ReindexMethod | None = ..., limit=..., tolerance=...
): ...
Expand Down Expand Up @@ -400,7 +400,14 @@ class Index(IndexOpsMixin[S1]):
def identical(self, other) -> bool: ...
def asof(self, label): ...
def asof_locs(self, where, mask): ...
def sort_values(self, return_indexer: bool = ..., ascending: bool = ...): ...
def sort_values(
self,
*,
return_indexer: bool = ...,
ascending: bool = ...,
na_position: Literal["first", "last"] = ...,
key: Callable | None = None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
key: Callable | None = None,
key: Callable[[Index], Index] | None = None,

according to the docs, it has to take an Index and return an Index

): ...
def sort(self, *args, **kwargs) -> None: ...
def argsort(self, *args, **kwargs): ...
def get_indexer_non_unique(self, target): ...
Expand Down
4 changes: 3 additions & 1 deletion pandas-stubs/core/indexes/category.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ class CategoricalIndex(ExtensionIndex[S1], accessor.PandasDelegate):
@property
def values(self): ...
def __contains__(self, key) -> bool: ...
def __array__(self, dtype=...) -> np.ndarray: ...
def __array__(
self, dtype: DtypeArg = ..., copy: bool | None = ...
) -> np.ndarray: ...
def astype(self, dtype: DtypeArg, copy: bool = ...) -> Index: ...
def fillna(self, value=...): ...
@property
Expand Down
7 changes: 6 additions & 1 deletion pandas-stubs/core/indexes/multi.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ from collections.abc import (
Sequence,
)
from typing import (
Literal,
overload,
)

Expand Down Expand Up @@ -140,7 +141,11 @@ class MultiIndex(Index):
def swaplevel(self, i: int = ..., j: int = ...): ...
def reorder_levels(self, order): ...
def sortlevel(
self, level: int = ..., ascending: bool = ..., sort_remaining: bool = ...
self,
level: int = ...,
ascending: bool = ...,
sort_remaining: bool = ...,
na_position: Literal["first", "last"] = ...,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use NaPosition from _typing

): ...
def get_indexer(self, target, method=..., limit=..., tolerance=...): ...
def get_indexer_non_unique(self, target): ...
Expand Down
2 changes: 0 additions & 2 deletions pandas-stubs/core/interchange/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
from pandas.core.interchange.dataframe_protocol import DataFrame as DataFrame
from pandas.core.interchange.from_dataframe import from_dataframe as from_dataframe
10 changes: 7 additions & 3 deletions pandas-stubs/core/resample.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ _SeriesGroupByFuncArgs: TypeAlias = (
)

class Resampler(BaseGroupBy[NDFrameT]):
grouper: BinGrouper # pyright: ignore[reportIncompatibleVariableOverride] # pyrefly: ignore # variance incompatibility
_grouper: BinGrouper
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should delete this - not documented

binner: DatetimeIndex | TimedeltaIndex | PeriodIndex
exclusions: frozenset[Hashable]
ax: Index
Expand Down Expand Up @@ -123,8 +123,12 @@ class Resampler(BaseGroupBy[NDFrameT]):
def prod(self, numeric_only: bool = ..., min_count: int = ...) -> NDFrameT: ...
def min(self, numeric_only: bool = ..., min_count: int = ...) -> NDFrameT: ...
def max(self, numeric_only: bool = ..., min_count: int = ...) -> NDFrameT: ...
def first(self, numeric_only: bool = ..., min_count: int = ...) -> NDFrameT: ...
def last(self, numeric_only: bool = ..., min_count: int = ...) -> NDFrameT: ...
def first(
self, numeric_only: bool = ..., min_count: int = ..., skipna: bool = ...
) -> NDFrameT: ...
def last(
self, numeric_only: bool = ..., min_count: int = ..., skipna: bool = ...
) -> NDFrameT: ...
def median(self, numeric_only: bool = ...) -> NDFrameT: ...
def mean(self, numeric_only: bool = ...) -> NDFrameT: ...
def std(self, ddof: int = ..., numeric_only: bool = ...) -> NDFrameT: ...
Expand Down
2 changes: 2 additions & 0 deletions tests/test_resampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ def test_agg_funcs() -> None:
check(assert_type(DF.resample("ME").min(), DataFrame), DataFrame)
check(assert_type(DF.resample("ME").max(), DataFrame), DataFrame)
check(assert_type(DF.resample("ME").first(), DataFrame), DataFrame)
check(assert_type(DF.resample("ME").first(skipna=False), DataFrame), DataFrame)
check(assert_type(DF.resample("ME").last(), DataFrame), DataFrame)
check(assert_type(DF.resample("ME").last(skipna=False), DataFrame), DataFrame)
check(assert_type(DF.resample("ME").mean(), DataFrame), DataFrame)
check(assert_type(DF.resample("ME").sum(), DataFrame), DataFrame)
check(assert_type(DF.resample("ME").median(), DataFrame), DataFrame)
Expand Down