Skip to content

Commit 2339f31

Browse files
authored
TYP: fix almost all keyword-only reported by stubtest (#474)
* TYP: fix almost all keyword-only reported by stubtest * opened pandas PR to make NDFame.fillna keyword-only * duplicate overloads to make mypy pass * address comments * remaining comments
1 parent 9e9f840 commit 2339f31

26 files changed

+172
-236
lines changed

pandas-stubs/_libs/tslibs/timestamps.pyi

-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ class Timestamp(datetime):
142142
second: int | None = ...,
143143
microsecond: int | None = ...,
144144
tzinfo: _tzinfo | None = ...,
145-
*,
146145
fold: Literal[0, 1] | None = ...,
147146
) -> Timestamp: ...
148147
def astimezone(self: _DatetimeT, tz: _tzinfo | None = ...) -> _DatetimeT: ...

pandas-stubs/core/algorithms.pyi

-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ def unique(values: ExtensionArray) -> ExtensionArray: ...
4040
def factorize(
4141
values: Sequence,
4242
sort: bool = ...,
43-
# Not actually positional-only, used to handle deprecations in 1.5.0
44-
*,
4543
use_na_sentinel: bool = ...,
4644
size_hint: int | None = ...,
4745
) -> tuple[np.ndarray, np.ndarray]: ...

pandas-stubs/core/arrays/base.pyi

+2-4
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,9 @@ class ExtensionArray:
4242
) -> ABCExtensionArray: ...
4343
def unique(self): ...
4444
def searchsorted(self, value, side: str = ..., sorter=...): ...
45+
# TODO: remove keyword-only when pandas removed na_sentinel
4546
def factorize(
46-
self,
47-
# Not actually positional-only, used to handle deprecations in 1.5.0
48-
*,
49-
use_na_sentinel: bool = ...,
47+
self, *, use_na_sentinel: bool = ...
5048
) -> tuple[np.ndarray, ABCExtensionArray]: ...
5149
def repeat(self, repeats, axis=...): ...
5250
def take(

pandas-stubs/core/arrays/boolean.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ class BooleanArray(BaseMaskedArray):
2525
def __array_ufunc__(self, ufunc, method, *inputs, **kwargs): ...
2626
def __setitem__(self, key, value) -> None: ...
2727
def astype(self, dtype, copy: bool = ...): ...
28-
def any(self, skipna: bool = ..., **kwargs): ...
29-
def all(self, skipna: bool = ..., **kwargs): ...
28+
def any(self, *, skipna: bool = ..., **kwargs): ...
29+
def all(self, *, skipna: bool = ..., **kwargs): ...

pandas-stubs/core/arrays/categorical.pyi

+5-5
Original file line numberDiff line numberDiff line change
@@ -158,22 +158,22 @@ class Categorical(ExtensionArray, PandasObject):
158158
def dropna(self): ...
159159
def value_counts(self, dropna: bool = ...): ...
160160
def check_for_ordered(self, op) -> None: ...
161-
def argsort(self, ascending: bool = ..., kind: str = ..., *args, **kwargs): ...
161+
def argsort(self, *, ascending: bool = ..., kind: str = ..., **kwargs): ...
162162
def sort_values(
163-
self, inplace: bool = ..., ascending: bool = ..., na_position: str = ...
163+
self, *, inplace: bool = ..., ascending: bool = ..., na_position: str = ...
164164
): ...
165165
def view(self, dtype=...): ...
166166
def to_dense(self): ...
167167
def fillna(self, value=..., method=..., limit=...): ...
168-
def take(self, indexer, allow_fill: bool = ..., fill_value=...): ...
168+
def take(self, indexer, *, allow_fill: bool = ..., fill_value=...): ...
169169
def take_nd(self, indexer, allow_fill: bool = ..., fill_value=...): ...
170170
def __len__(self) -> int: ...
171171
def __iter__(self): ...
172172
def __contains__(self, key) -> bool: ...
173173
def __getitem__(self, key): ...
174174
def __setitem__(self, key, value) -> None: ...
175-
def min(self, skipna: bool = ...): ...
176-
def max(self, skipna: bool = ...): ...
175+
def min(self, *, skipna: bool = ...): ...
176+
def max(self, *, skipna: bool = ...): ...
177177
def mode(self, dropna: bool = ...): ...
178178
def unique(self): ...
179179
def equals(self, other): ...

pandas-stubs/core/arrays/datetimelike.pyi

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class DatetimeLikeArrayMixin(ExtensionOpsMixin, ExtensionArray):
4040
def astype(self, dtype, copy: bool = ...): ...
4141
def view(self, dtype=...): ...
4242
def unique(self): ...
43-
def take(self, indices, allow_fill: bool = ..., fill_value=...): ...
43+
def take(self, indices, *, allow_fill: bool = ..., fill_value=...): ...
4444
def copy(self): ...
4545
def shift(self, periods: int = ..., fill_value=..., axis: int = ...): ...
4646
def searchsorted(self, value, side: str = ..., sorter=...): ...
@@ -77,8 +77,8 @@ class DatetimeLikeArrayMixin(ExtensionOpsMixin, ExtensionArray):
7777
def __rsub__(self, other): ...
7878
def __iadd__(self, other): ...
7979
def __isub__(self, other): ...
80-
def min(self, axis=..., skipna: bool = ..., *args, **kwargs): ...
81-
def max(self, axis=..., skipna: bool = ..., *args, **kwargs): ...
82-
def mean(self, skipna: bool = ...): ...
80+
def min(self, *, axis=..., skipna: bool = ..., **kwargs): ...
81+
def max(self, *, axis=..., skipna: bool = ..., **kwargs): ...
82+
def mean(self, *, skipna: bool = ...): ...
8383

8484
def maybe_infer_freq(freq): ...

pandas-stubs/core/arrays/masked.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ class BaseMaskedArray(ExtensionArray, ExtensionOpsMixin):
2626
def isna(self): ...
2727
@property
2828
def nbytes(self) -> int: ...
29-
def take(self, indexer, allow_fill: bool = ..., fill_value=...): ...
29+
def take(self, indexer, *, allow_fill: bool = ..., fill_value=...): ...
3030
def copy(self): ...
3131
def value_counts(self, dropna: bool = ...): ...

pandas-stubs/core/arrays/sparse/array.pyi

+2-6
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,11 @@ class SparseArray(PandasObject, ExtensionArray, ExtensionOpsMixin):
4343
def shift(self, periods: int = ..., fill_value=...): ...
4444
def unique(self): ...
4545
def factorize( # type: ignore[override]
46-
self,
47-
na_sentinel: int = ...,
48-
# Not actually positional-only, used to handle deprecations in 1.5.0
49-
*,
50-
use_na_sentinel: bool = ...,
46+
self, na_sentinel: int = ..., use_na_sentinel: bool = ...
5147
) -> tuple[np.ndarray, SparseArray]: ...
5248
def value_counts(self, dropna: bool = ...): ...
5349
def __getitem__(self, key): ...
54-
def take(self, indices, allow_fill: bool = ..., fill_value=...): ...
50+
def take(self, indices, *, allow_fill: bool = ..., fill_value=...): ...
5551
def searchsorted(self, v, side: str = ..., sorter=...): ...
5652
def copy(self): ...
5753
def astype(self, dtype=..., copy: bool = ...): ...

pandas-stubs/core/base.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,5 @@ class IndexOpsMixin:
8787
self, value, side: Literal["left", "right"] = ..., sorter=...
8888
) -> int | list[int]: ...
8989
def drop_duplicates(
90-
self, keep: NaPosition | Literal[False] = ...
90+
self, *, keep: NaPosition | Literal[False] = ...
9191
) -> IndexOpsMixin: ...

pandas-stubs/core/computation/eval.pyi

-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ def eval(
1919
expr: str | BinOp,
2020
parser: Literal["pandas", "python"] = ...,
2121
engine: Literal["python", "numexpr"] | None = ...,
22-
# Keyword only due to omitted deprecated argument
23-
*,
2422
local_dict: dict[str, Any] | None = ...,
2523
global_dict: dict[str, Any] | None = ...,
2624
resolvers: list[Mapping] | None = ...,

0 commit comments

Comments
 (0)