Skip to content

Commit 8a4afc8

Browse files
committed
mypy, ty
1 parent e0b46da commit 8a4afc8

File tree

5 files changed

+29
-15
lines changed

5 files changed

+29
-15
lines changed

pandas-stubs/_typing.pyi

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -963,9 +963,7 @@ ListLikeExceptSeriesAndStr: TypeAlias = (
963963
MutableSequence[Any] | np_1darray | tuple[Any, ...] | Index
964964
)
965965
ListLikeU: TypeAlias = Sequence | np_1darray | Series | Index
966-
ListLikeHashable: TypeAlias = (
967-
MutableSequence[HashableT] | np_1darray | tuple[HashableT, ...] | range
968-
)
966+
ListLikeHashable: TypeAlias = SequenceNotStr[HashableT] | np_1darray | range
969967

970968
class SupportsDType(Protocol[GenericT_co]):
971969
@property

pandas-stubs/core/frame.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
11741174
@overload
11751175
def sort_values(
11761176
self,
1177-
by: _str | Sequence[_str],
1177+
by: _str | SequenceNotStr[_str],
11781178
*,
11791179
axis: Axis = 0,
11801180
ascending: _bool | Sequence[_bool] = ...,
@@ -1187,7 +1187,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
11871187
@overload
11881188
def sort_values(
11891189
self,
1190-
by: _str | Sequence[_str],
1190+
by: _str | SequenceNotStr[_str],
11911191
*,
11921192
axis: Axis = 0,
11931193
ascending: _bool | Sequence[_bool] = ...,

pandas-stubs/core/groupby/generic.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ class DataFrameGroupBy(GroupBy[DataFrame], Generic[ByT, _TT]):
261261
@overload
262262
def aggregate(
263263
self,
264-
func: AggFuncTypeFrame[Hashable] | None = ...,
264+
func: AggFuncTypeFrame[Any] | None = ...,
265265
*args: Any,
266266
engine: WindowingEngine = ...,
267267
engine_kwargs: WindowingEngineKwargs = ...,
@@ -270,7 +270,7 @@ class DataFrameGroupBy(GroupBy[DataFrame], Generic[ByT, _TT]):
270270
@overload
271271
def aggregate(
272272
self,
273-
func: AggFuncTypeFrame[Hashable] | None = None,
273+
func: AggFuncTypeFrame[Any] | None = None,
274274
/,
275275
**kwargs: Any,
276276
) -> DataFrame: ...

pandas-stubs/core/reshape/pivot.pyi

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,13 @@ _ExtendedAnyArrayLike: TypeAlias = AnyArrayLike | ArrayLike
6666
@overload
6767
def pivot_table(
6868
data: DataFrame,
69-
values: _PivotTableValuesTypes[Hashable] = None,
70-
index: _PivotTableIndexTypes[Hashable] = None,
71-
columns: _PivotTableColumnsTypes[Hashable] = None,
69+
values: _PivotTableValuesTypes[
70+
Hashable # ty: ignore[invalid-type-arguments]
71+
] = None,
72+
index: _PivotTableIndexTypes[Hashable] = None, # ty: ignore[invalid-type-arguments]
73+
columns: _PivotTableColumnsTypes[
74+
Hashable # ty: ignore[invalid-type-arguments]
75+
] = None,
7276
aggfunc: (
7377
_PivotAggFunc[Any]
7478
| Sequence[_PivotAggFunc[Any]]
@@ -86,10 +90,16 @@ def pivot_table(
8690
@overload
8791
def pivot_table(
8892
data: DataFrame,
89-
values: _PivotTableValuesTypes[Hashable] = None,
93+
values: _PivotTableValuesTypes[
94+
Hashable # ty: ignore[invalid-type-arguments]
95+
] = None,
9096
*,
9197
index: Grouper,
92-
columns: _PivotTableColumnsTypes[Hashable] | np_ndarray | Index[Any] = None,
98+
columns: (
99+
_PivotTableColumnsTypes[Hashable] # ty: ignore[invalid-type-arguments]
100+
| np_ndarray
101+
| Index[Any]
102+
) = None,
93103
aggfunc: (
94104
_PivotAggFunc[Any]
95105
| Sequence[_PivotAggFunc[Any]]
@@ -105,8 +115,14 @@ def pivot_table(
105115
@overload
106116
def pivot_table(
107117
data: DataFrame,
108-
values: _PivotTableValuesTypes[Hashable] = None,
109-
index: _PivotTableIndexTypes[Hashable] | np_ndarray | Index[Any] = None,
118+
values: _PivotTableValuesTypes[
119+
Hashable # ty: ignore[invalid-type-arguments]
120+
] = None,
121+
index: (
122+
_PivotTableIndexTypes[Hashable] # ty: ignore[invalid-type-arguments]
123+
| np_ndarray
124+
| Index[Any]
125+
) = None,
110126
*,
111127
columns: Grouper,
112128
aggfunc: (

tests/extension/decimal/array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ def convert_values(param: Any) -> ExtensionArray | list[Any]:
344344
return cast(np_1darray_bool, np.asarray(res, dtype=bool))
345345

346346
def value_counts(self, dropna: bool = True) -> Series:
347-
from pandas.core.algorithms import (
347+
from pandas.core.algorithms import ( # type: ignore[attr-defined] # isort: skip
348348
value_counts, # pyright: ignore[reportAttributeAccessIssue,reportUnknownVariableType]
349349
)
350350

0 commit comments

Comments
 (0)