From 42e15e89c1ba0ca033c3df25f1ad75a13384ebda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20W=C3=B6rtwein?= Date: Sun, 18 Sep 2022 13:14:23 -0400 Subject: [PATCH 1/6] stubtest inconsistencies --- pandas-stubs/_libs/tslibs/timestamps.pyi | 2 +- pandas-stubs/_testing/__init__.pyi | 1 + pandas-stubs/core/indexes/timedeltas.pyi | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pandas-stubs/_libs/tslibs/timestamps.pyi b/pandas-stubs/_libs/tslibs/timestamps.pyi index ff78adc63..2a5d41cc0 100644 --- a/pandas-stubs/_libs/tslibs/timestamps.pyi +++ b/pandas-stubs/_libs/tslibs/timestamps.pyi @@ -77,7 +77,7 @@ class Timestamp(datetime): cls: type[_DatetimeT], t: float, tz: _tzinfo | None = ... ) -> _DatetimeT: ... @classmethod - def utcfromtimestamp(cls: type[_DatetimeT], t: float) -> _DatetimeT: ... + def utcfromtimestamp(cls: type[_DatetimeT], ts: float) -> _DatetimeT: ... @classmethod def today(cls: type[_DatetimeT], tz: _tzinfo | str | None = ...) -> _DatetimeT: ... @classmethod diff --git a/pandas-stubs/_testing/__init__.pyi b/pandas-stubs/_testing/__init__.pyi index f761aca5d..eb70b8926 100644 --- a/pandas-stubs/_testing/__init__.pyi +++ b/pandas-stubs/_testing/__init__.pyi @@ -60,6 +60,7 @@ def assert_series_equal( check_dtype: bool = ..., check_index_type: bool | str = ..., check_series_type: bool = ..., + check_less_precise: bool | int = ..., check_names: bool = ..., check_exact: bool = ..., check_datetimelike_compat: bool = ..., diff --git a/pandas-stubs/core/indexes/timedeltas.pyi b/pandas-stubs/core/indexes/timedeltas.pyi index 113c2d50e..680e4a635 100644 --- a/pandas-stubs/core/indexes/timedeltas.pyi +++ b/pandas-stubs/core/indexes/timedeltas.pyi @@ -34,9 +34,9 @@ class TimedeltaIndex(DatetimeTimedeltaMixin, TimedeltaIndexProperties): def __truediv__(self, other: num) -> TimedeltaIndex: ... # type: ignore[override] def astype(self, dtype, copy: bool = ...): ... def get_value(self, series, key): ... - def get_loc(self, key, tolerance=...): ... + def get_loc(self, key, method=..., tolerance=...): ... def searchsorted(self, value, side: str = ..., sorter=...): ... - def is_type_compatible(self, typ) -> bool: ... + def is_type_compatible(self, kind: str) -> bool: ... @property def inferred_type(self) -> str: ... def insert(self, loc, item): ... From 6827c7da8be2643bcf330dd697706ced66c9ab7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20W=C3=B6rtwein?= Date: Sun, 18 Sep 2022 13:23:59 -0400 Subject: [PATCH 2/6] remove deprecated --- pandas-stubs/_testing/__init__.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas-stubs/_testing/__init__.pyi b/pandas-stubs/_testing/__init__.pyi index eb70b8926..f761aca5d 100644 --- a/pandas-stubs/_testing/__init__.pyi +++ b/pandas-stubs/_testing/__init__.pyi @@ -60,7 +60,6 @@ def assert_series_equal( check_dtype: bool = ..., check_index_type: bool | str = ..., check_series_type: bool = ..., - check_less_precise: bool | int = ..., check_names: bool = ..., check_exact: bool = ..., check_datetimelike_compat: bool = ..., From 43fdc064c90250b3fd319b8b1c045585f650b9a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20W=C3=B6rtwein?= Date: Tue, 20 Sep 2022 19:00:53 -0400 Subject: [PATCH 3/6] fix some keyword-only arguments --- pandas-stubs/core/arrays/base.pyi | 2 +- pandas-stubs/core/arrays/interval.pyi | 2 +- pandas-stubs/core/arrays/numpy_.pyi | 20 +++++++++++++------- pandas-stubs/core/arrays/string_.pyi | 4 ++-- pandas-stubs/core/arrays/timedeltas.pyi | 3 +++ pandas-stubs/core/frame.pyi | 1 + pandas-stubs/core/indexes/timedeltas.pyi | 2 +- pandas-stubs/core/missing.pyi | 2 +- pandas-stubs/core/series.pyi | 2 +- pandas-stubs/util/_test_decorators.pyi | 4 +--- 10 files changed, 25 insertions(+), 17 deletions(-) diff --git a/pandas-stubs/core/arrays/base.pyi b/pandas-stubs/core/arrays/base.pyi index 895da26b1..b761d7d95 100644 --- a/pandas-stubs/core/arrays/base.pyi +++ b/pandas-stubs/core/arrays/base.pyi @@ -47,7 +47,7 @@ class ExtensionArray: ) -> tuple[np.ndarray, ABCExtensionArray]: ... def repeat(self, repeats, axis=...): ... def take( - self, indices: Sequence[int], allow_fill: bool = ..., fill_value=... + self, indices: Sequence[int], *, allow_fill: bool = ..., fill_value=... ) -> ABCExtensionArray: ... def copy(self) -> ABCExtensionArray: ... def view(self, dtype=...) -> ABCExtensionArray | np.ndarray: ... diff --git a/pandas-stubs/core/arrays/interval.pyi b/pandas-stubs/core/arrays/interval.pyi index 1709179f1..1b63ed724 100644 --- a/pandas-stubs/core/arrays/interval.pyi +++ b/pandas-stubs/core/arrays/interval.pyi @@ -44,7 +44,7 @@ class IntervalArray(IntervalMixin, ExtensionArray): self, periods: int = ..., fill_value: object = ... ) -> ABCExtensionArray: ... def take( - self, indices, allow_fill: bool = ..., fill_value=..., axis=..., **kwargs + self, indices, *, allow_fill: bool = ..., fill_value=..., axis=..., **kwargs ): ... def value_counts(self, dropna: bool = ...): ... @property diff --git a/pandas-stubs/core/arrays/numpy_.pyi b/pandas-stubs/core/arrays/numpy_.pyi index 96a12ea70..2df7e4f11 100644 --- a/pandas-stubs/core/arrays/numpy_.pyi +++ b/pandas-stubs/core/arrays/numpy_.pyi @@ -46,12 +46,13 @@ class PandasArray(ExtensionArray, ExtensionOpsMixin, NDArrayOperatorsMixin): def take(self, indices, allow_fill: bool = ..., fill_value=...): ... def copy(self): ... def unique(self): ... - def any(self, axis=..., out=..., keepdims: bool = ..., skipna: bool = ...): ... - def all(self, axis=..., out=..., keepdims: bool = ..., skipna: bool = ...): ... - def min(self, axis=..., out=..., keepdims: bool = ..., skipna: bool = ...): ... - def max(self, axis=..., out=..., keepdims: bool = ..., skipna: bool = ...): ... + def any(self, *, axis=..., out=..., keepdims: bool = ..., skipna: bool = ...): ... + def all(self, *, axis=..., out=..., keepdims: bool = ..., skipna: bool = ...): ... + def min(self, *, axis=..., out=..., keepdims: bool = ..., skipna: bool = ...): ... + def max(self, *, axis=..., out=..., keepdims: bool = ..., skipna: bool = ...): ... def sum( self, + *, axis=..., dtype=..., out=..., @@ -62,6 +63,7 @@ class PandasArray(ExtensionArray, ExtensionOpsMixin, NDArrayOperatorsMixin): ): ... def prod( self, + *, axis=..., dtype=..., out=..., @@ -71,10 +73,11 @@ class PandasArray(ExtensionArray, ExtensionOpsMixin, NDArrayOperatorsMixin): min_count: int = ..., ): ... def mean( - self, axis=..., dtype=..., out=..., keepdims: bool = ..., skipna: bool = ... + self, *, axis=..., dtype=..., out=..., keepdims: bool = ..., skipna: bool = ... ): ... def median( self, + *, axis=..., out=..., overwrite_input: bool = ..., @@ -83,6 +86,7 @@ class PandasArray(ExtensionArray, ExtensionOpsMixin, NDArrayOperatorsMixin): ): ... def std( self, + *, axis=..., dtype=..., out=..., @@ -92,6 +96,7 @@ class PandasArray(ExtensionArray, ExtensionOpsMixin, NDArrayOperatorsMixin): ): ... def var( self, + *, axis=..., dtype=..., out=..., @@ -101,6 +106,7 @@ class PandasArray(ExtensionArray, ExtensionOpsMixin, NDArrayOperatorsMixin): ): ... def sem( self, + *, axis=..., dtype=..., out=..., @@ -109,10 +115,10 @@ class PandasArray(ExtensionArray, ExtensionOpsMixin, NDArrayOperatorsMixin): skipna: bool = ..., ): ... def kurt( - self, axis=..., dtype=..., out=..., keepdims: bool = ..., skipna: bool = ... + self, *, axis=..., dtype=..., out=..., keepdims: bool = ..., skipna: bool = ... ): ... def skew( - self, axis=..., dtype=..., out=..., keepdims: bool = ..., skipna: bool = ... + self, *, axis=..., dtype=..., out=..., keepdims: bool = ..., skipna: bool = ... ): ... def to_numpy( self, diff --git a/pandas-stubs/core/arrays/string_.pyi b/pandas-stubs/core/arrays/string_.pyi index 7cb83b8b0..700510120 100644 --- a/pandas-stubs/core/arrays/string_.pyi +++ b/pandas-stubs/core/arrays/string_.pyi @@ -1,8 +1,8 @@ -from pandas.core.arrays import PandasArray as PandasArray +from pandas.core.arrays import PandasArray from pandas._typing import type_t -from pandas.core.dtypes.base import ExtensionDtype as ExtensionDtype +from pandas.core.dtypes.base import ExtensionDtype class StringDtype(ExtensionDtype): name: str = ... diff --git a/pandas-stubs/core/arrays/timedeltas.pyi b/pandas-stubs/core/arrays/timedeltas.pyi index 89c31ad03..699f8b0f7 100644 --- a/pandas-stubs/core/arrays/timedeltas.pyi +++ b/pandas-stubs/core/arrays/timedeltas.pyi @@ -14,6 +14,7 @@ class TimedeltaArray(DatetimeLikeArrayMixin, TimelikeOps): def astype(self, dtype, copy: bool = ...): ... def sum( self, + *, axis=..., dtype=..., out=..., @@ -24,6 +25,7 @@ class TimedeltaArray(DatetimeLikeArrayMixin, TimelikeOps): ): ... def std( self, + *, axis=..., dtype=..., out=..., @@ -33,6 +35,7 @@ class TimedeltaArray(DatetimeLikeArrayMixin, TimelikeOps): ): ... def median( self, + *, axis=..., out=..., overwrite_input: bool = ..., diff --git a/pandas-stubs/core/frame.pyi b/pandas-stubs/core/frame.pyi index d271969aa..9717cb610 100644 --- a/pandas-stubs/core/frame.pyi +++ b/pandas-stubs/core/frame.pyi @@ -1787,6 +1787,7 @@ class DataFrame(NDFrame, OpsMixin): min_periods: int | None = ..., center: _bool = ..., *, + win_type: None = ..., on: Hashable | None = ..., axis: AxisType = ..., closed: IntervalClosedType | None = ..., diff --git a/pandas-stubs/core/indexes/timedeltas.pyi b/pandas-stubs/core/indexes/timedeltas.pyi index 680e4a635..08fa6e6a5 100644 --- a/pandas-stubs/core/indexes/timedeltas.pyi +++ b/pandas-stubs/core/indexes/timedeltas.pyi @@ -34,7 +34,7 @@ class TimedeltaIndex(DatetimeTimedeltaMixin, TimedeltaIndexProperties): def __truediv__(self, other: num) -> TimedeltaIndex: ... # type: ignore[override] def astype(self, dtype, copy: bool = ...): ... def get_value(self, series, key): ... - def get_loc(self, key, method=..., tolerance=...): ... + def get_loc(self, key, tolerance=...): ... def searchsorted(self, value, side: str = ..., sorter=...): ... def is_type_compatible(self, kind: str) -> bool: ... @property diff --git a/pandas-stubs/core/missing.pyi b/pandas-stubs/core/missing.pyi index 05a8ab7ac..b135728a5 100644 --- a/pandas-stubs/core/missing.pyi +++ b/pandas-stubs/core/missing.pyi @@ -1,7 +1,7 @@ def mask_missing(arr, values_to_mask): ... def clean_fill_method(method, allow_nearest: bool = ...): ... def clean_interp_method(method, **kwargs): ... -def find_valid_index(values, how: str): ... +def find_valid_index(values, how: str = ...): ... def interpolate_2d( values, method: str = ..., axis: int = ..., limit=..., fill_value=..., dtype=... ): ... diff --git a/pandas-stubs/core/series.pyi b/pandas-stubs/core/series.pyi index 5e3ef2d66..0249bb5c8 100644 --- a/pandas-stubs/core/series.pyi +++ b/pandas-stubs/core/series.pyi @@ -1391,7 +1391,6 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]): self, axis: SeriesAxisType | None = ..., skipna: _bool = ..., - *, level: None = ..., numeric_only: _bool | None = ..., **kwargs, @@ -1528,6 +1527,7 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]): min_periods: int | None = ..., center: _bool = ..., *, + win_type: None = ..., on: _str | None = ..., axis: SeriesAxisType = ..., closed: _str | None = ..., diff --git a/pandas-stubs/util/_test_decorators.pyi b/pandas-stubs/util/_test_decorators.pyi index 7496c9742..c10d79493 100644 --- a/pandas-stubs/util/_test_decorators.pyi +++ b/pandas-stubs/util/_test_decorators.pyi @@ -13,9 +13,7 @@ skip_if_not_us_locale = ... skip_if_no_scipy = ... skip_if_no_ne = ... -def skip_if_np_lt( - ver_str: str, reason: str | None = ..., *args, **kwds -) -> Callable: ... +def skip_if_np_lt(ver_str: str, *args, reason: str | None = ...) -> Callable: ... def parametrize_fixture_doc(*args): ... def check_file_leaks(func) -> Callable: ... def async_mark(): ... From 5b88525490a9dd635ac6dbf50b98acda60b0c7be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20W=C3=B6rtwein?= Date: Wed, 21 Sep 2022 09:04:02 -0400 Subject: [PATCH 4/6] comments --- pandas-stubs/core/indexes/timedeltas.pyi | 1 - pandas-stubs/core/missing.pyi | 1 - pandas-stubs/util/_test_decorators.pyi | 19 ------------------- 3 files changed, 21 deletions(-) delete mode 100644 pandas-stubs/util/_test_decorators.pyi diff --git a/pandas-stubs/core/indexes/timedeltas.pyi b/pandas-stubs/core/indexes/timedeltas.pyi index 08fa6e6a5..962270e33 100644 --- a/pandas-stubs/core/indexes/timedeltas.pyi +++ b/pandas-stubs/core/indexes/timedeltas.pyi @@ -36,7 +36,6 @@ class TimedeltaIndex(DatetimeTimedeltaMixin, TimedeltaIndexProperties): def get_value(self, series, key): ... def get_loc(self, key, tolerance=...): ... def searchsorted(self, value, side: str = ..., sorter=...): ... - def is_type_compatible(self, kind: str) -> bool: ... @property def inferred_type(self) -> str: ... def insert(self, loc, item): ... diff --git a/pandas-stubs/core/missing.pyi b/pandas-stubs/core/missing.pyi index b135728a5..f9aa667ee 100644 --- a/pandas-stubs/core/missing.pyi +++ b/pandas-stubs/core/missing.pyi @@ -1,7 +1,6 @@ def mask_missing(arr, values_to_mask): ... def clean_fill_method(method, allow_nearest: bool = ...): ... def clean_interp_method(method, **kwargs): ... -def find_valid_index(values, how: str = ...): ... def interpolate_2d( values, method: str = ..., axis: int = ..., limit=..., fill_value=..., dtype=... ): ... diff --git a/pandas-stubs/util/_test_decorators.pyi b/pandas-stubs/util/_test_decorators.pyi deleted file mode 100644 index c10d79493..000000000 --- a/pandas-stubs/util/_test_decorators.pyi +++ /dev/null @@ -1,19 +0,0 @@ -from typing import Callable - -def safe_import(mod_name: str, min_version: str | None = ...): ... -def skip_if_installed(package: str) -> Callable: ... -def skip_if_no(package: str, min_version: str | None = ...) -> Callable: ... - -skip_if_no_mpl = ... -skip_if_mpl = ... -skip_if_32bit = ... -skip_if_windows = ... -skip_if_has_locale = ... -skip_if_not_us_locale = ... -skip_if_no_scipy = ... -skip_if_no_ne = ... - -def skip_if_np_lt(ver_str: str, *args, reason: str | None = ...) -> Callable: ... -def parametrize_fixture_doc(*args): ... -def check_file_leaks(func) -> Callable: ... -def async_mark(): ... From c4837689e7efd26c2379703aec3566f97db8730b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20W=C3=B6rtwein?= Date: Wed, 21 Sep 2022 10:24:48 -0400 Subject: [PATCH 5/6] thin PandasArray --- pandas-stubs/core/arrays/numpy_.pyi | 97 ----------------------------- 1 file changed, 97 deletions(-) diff --git a/pandas-stubs/core/arrays/numpy_.pyi b/pandas-stubs/core/arrays/numpy_.pyi index 2df7e4f11..e4f869aa6 100644 --- a/pandas-stubs/core/arrays/numpy_.pyi +++ b/pandas-stubs/core/arrays/numpy_.pyi @@ -30,101 +30,4 @@ class PandasDtype(ExtensionDtype): def itemsize(self): ... class PandasArray(ExtensionArray, ExtensionOpsMixin, NDArrayOperatorsMixin): - __array_priority__: int = ... - def __init__(self, values: np.ndarray | PandasArray, copy: bool = ...) -> None: ... - @property - def dtype(self): ... - def __array__(self, dtype=...) -> np.ndarray: ... def __array_ufunc__(self, ufunc, method, *inputs, **kwargs): ... - def __getitem__(self, item): ... - def __setitem__(self, key, value) -> None: ... - def __len__(self) -> int: ... - @property - def nbytes(self) -> int: ... - def isna(self): ... - def fillna(self, value=..., method=..., limit=...): ... - def take(self, indices, allow_fill: bool = ..., fill_value=...): ... - def copy(self): ... - def unique(self): ... - def any(self, *, axis=..., out=..., keepdims: bool = ..., skipna: bool = ...): ... - def all(self, *, axis=..., out=..., keepdims: bool = ..., skipna: bool = ...): ... - def min(self, *, axis=..., out=..., keepdims: bool = ..., skipna: bool = ...): ... - def max(self, *, axis=..., out=..., keepdims: bool = ..., skipna: bool = ...): ... - def sum( - self, - *, - axis=..., - dtype=..., - out=..., - keepdims: bool = ..., - initial=..., - skipna: bool = ..., - min_count: int = ..., - ): ... - def prod( - self, - *, - axis=..., - dtype=..., - out=..., - keepdims: bool = ..., - initial=..., - skipna: bool = ..., - min_count: int = ..., - ): ... - def mean( - self, *, axis=..., dtype=..., out=..., keepdims: bool = ..., skipna: bool = ... - ): ... - def median( - self, - *, - axis=..., - out=..., - overwrite_input: bool = ..., - keepdims: bool = ..., - skipna: bool = ..., - ): ... - def std( - self, - *, - axis=..., - dtype=..., - out=..., - ddof: int = ..., - keepdims: bool = ..., - skipna: bool = ..., - ): ... - def var( - self, - *, - axis=..., - dtype=..., - out=..., - ddof: int = ..., - keepdims: bool = ..., - skipna: bool = ..., - ): ... - def sem( - self, - *, - axis=..., - dtype=..., - out=..., - ddof: int = ..., - keepdims: bool = ..., - skipna: bool = ..., - ): ... - def kurt( - self, *, axis=..., dtype=..., out=..., keepdims: bool = ..., skipna: bool = ... - ): ... - def skew( - self, *, axis=..., dtype=..., out=..., keepdims: bool = ..., skipna: bool = ... - ): ... - def to_numpy( - self, - dtype: npt.DTypeLike | None = ..., - copy: bool = ..., - na_value: Scalar = ..., - ) -> np.ndarray: ... - def searchsorted(self, value, side: str = ..., sorter=...): ... - def __invert__(self): ... From f755e476ddb858d5b2eb27e4e4b6fbdf48c137a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20W=C3=B6rtwein?= Date: Wed, 21 Sep 2022 10:39:53 -0400 Subject: [PATCH 6/6] remove imports --- pandas-stubs/core/arrays/numpy_.pyi | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pandas-stubs/core/arrays/numpy_.pyi b/pandas-stubs/core/arrays/numpy_.pyi index e4f869aa6..f44e5a6af 100644 --- a/pandas-stubs/core/arrays/numpy_.pyi +++ b/pandas-stubs/core/arrays/numpy_.pyi @@ -5,11 +5,6 @@ from pandas.core.arrays.base import ( ExtensionOpsMixin, ) -from pandas._typing import ( - Scalar, - npt, -) - from pandas.core.dtypes.dtypes import ExtensionDtype class PandasDtype(ExtensionDtype):