Skip to content

Commit de187d6

Browse files
committed
TYP: fix almost all keyword-only reported by stubtest
1 parent 288f9df commit de187d6

25 files changed

+178
-235
lines changed

pandas-stubs/_libs/tslibs/timestamps.pyi

+3-4
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,19 @@ class Timestamp(datetime):
5656
# Freq is deprecated but is left in to allow code like Timestamp(2000,1,1)
5757
# Removing it would make the other arguments position only
5858
freq: int | str | BaseOffset | None = ...,
59-
tz: str | _tzinfo | int | None = ...,
60-
unit: str | int | None = ...,
6159
year: int | None = ...,
6260
month: int | None = ...,
6361
day: int | None = ...,
6462
hour: int | None = ...,
6563
minute: int | None = ...,
6664
second: int | None = ...,
6765
microsecond: int | None = ...,
68-
nanosecond: int | None = ...,
6966
tzinfo: _tzinfo | None = ...,
7067
*,
68+
unit: str | int | None = ...,
69+
tz: str | _tzinfo | int | None = ...,
7170
fold: Literal[0, 1] | None = ...,
71+
nanosecond: int | None = ...,
7272
) -> _DatetimeT: ...
7373
# GH 46171
7474
# While Timestamp can return pd.NaT, having the constructor return
@@ -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
@@ -42,8 +42,6 @@ def unique(values: ExtensionArray) -> ExtensionArray: ...
4242
def factorize(
4343
values: Sequence,
4444
sort: bool = ...,
45-
# Not actually positional-only, used to handle deprecations in 1.5.0
46-
*,
4745
use_na_sentinel: bool = ...,
4846
size_hint: int | None = ...,
4947
) -> tuple[np.ndarray, np.ndarray]: ...

pandas-stubs/core/arrays/base.pyi

+1-4
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ class ExtensionArray:
4343
def unique(self): ...
4444
def searchsorted(self, value, side: str = ..., sorter=...): ...
4545
def factorize(
46-
self,
47-
# Not actually positional-only, used to handle deprecations in 1.5.0
48-
*,
49-
use_na_sentinel: bool = ...,
46+
self, use_na_sentinel: bool = ...
5047
) -> tuple[np.ndarray, ABCExtensionArray]: ...
5148
def repeat(self, repeats, axis=...): ...
5249
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
@@ -156,22 +156,22 @@ class Categorical(ExtensionArray, PandasObject):
156156
def dropna(self): ...
157157
def value_counts(self, dropna: bool = ...): ...
158158
def check_for_ordered(self, op) -> None: ...
159-
def argsort(self, ascending: bool = ..., kind: str = ..., *args, **kwargs): ...
159+
def argsort(self, *, ascending: bool = ..., kind: str = ..., **kwargs): ...
160160
def sort_values(
161-
self, inplace: bool = ..., ascending: bool = ..., na_position: str = ...
161+
self, *, inplace: bool = ..., ascending: bool = ..., na_position: str = ...
162162
): ...
163163
def view(self, dtype=...): ...
164164
def to_dense(self): ...
165165
def fillna(self, value=..., method=..., limit=...): ...
166-
def take(self, indexer, allow_fill: bool = ..., fill_value=...): ...
166+
def take(self, indexer, *, allow_fill: bool = ..., fill_value=...): ...
167167
def take_nd(self, indexer, allow_fill: bool = ..., fill_value=...): ...
168168
def __len__(self) -> int: ...
169169
def __iter__(self): ...
170170
def __contains__(self, key) -> bool: ...
171171
def __getitem__(self, key): ...
172172
def __setitem__(self, key, value) -> None: ...
173-
def min(self, skipna: bool = ...): ...
174-
def max(self, skipna: bool = ...): ...
173+
def min(self, *, skipna: bool = ...): ...
174+
def max(self, *, skipna: bool = ...): ...
175175
def mode(self, dropna: bool = ...): ...
176176
def unique(self): ...
177177
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)