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 = ..., diff --git a/pandas-stubs/core/frame.pyi b/pandas-stubs/core/frame.pyi index a0e46ba9e..8ad06b675 100644 --- a/pandas-stubs/core/frame.pyi +++ b/pandas-stubs/core/frame.pyi @@ -1428,9 +1428,7 @@ class DataFrame(NDFrame, OpsMixin): ignore_na: _bool = ..., axis: AxisType = ..., ) -> DataFrame: ... - def expanding( - self, min_periods: int = ..., center: _bool = ..., axis: AxisType = ... - ): ... # for now + def expanding(self, min_periods: int = ..., axis: AxisType = ...): ... # for now @overload def ffill( self, diff --git a/pandas-stubs/core/series.pyi b/pandas-stubs/core/series.pyi index 324796736..8d792f439 100644 --- a/pandas-stubs/core/series.pyi +++ b/pandas-stubs/core/series.pyi @@ -525,30 +525,31 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]): @overload def sort_values( self, + *, axis: AxisType = ..., ascending: _bool | Sequence[_bool] = ..., kind: SortKind = ..., na_position: NaPosition = ..., ignore_index: _bool = ..., - *, inplace: Literal[True], key: Callable | None = ..., ) -> None: ... @overload def sort_values( self, + *, axis: AxisType = ..., ascending: _bool | Sequence[_bool] = ..., kind: SortKind = ..., na_position: NaPosition = ..., ignore_index: _bool = ..., - *, inplace: Literal[False] = ..., key: Callable | None = ..., ) -> Series[S1]: ... @overload def sort_values( self, + *, axis: AxisType = ..., ascending: _bool | Sequence[_bool] = ..., inplace: _bool | None = ..., @@ -1325,7 +1326,7 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]): axis: SeriesAxisType = ..., ) -> ExponentialMovingWindow: ... def expanding( - self, min_periods: int = ..., center: _bool = ..., axis: SeriesAxisType = ... + self, min_periods: int = ..., axis: SeriesAxisType = ... ) -> DataFrame: ... def floordiv( self, diff --git a/tests/test_frame.py b/tests/test_frame.py index 1e38f8f4c..c726d45fb 100644 --- a/tests/test_frame.py +++ b/tests/test_frame.py @@ -33,7 +33,10 @@ from pandas._typing import Scalar -from tests import check +from tests import ( + TYPE_CHECKING_INVALID_USAGE, + check, +) from pandas.io.parsers import TextFileReader @@ -714,8 +717,9 @@ def test_types_plot() -> None: def test_types_window() -> None: df = pd.DataFrame(data={"col1": [1, 1, 2], "col2": [3, 4, 5]}) df.expanding() - with pytest.warns(FutureWarning, match="The `center` argument on"): - df.expanding(axis=1, center=True) + df.expanding(axis=1) + if TYPE_CHECKING_INVALID_USAGE: + df.expanding(axis=1, center=True) # type: ignore[call-arg] df.rolling(2) df.rolling(2, axis=1, center=True) diff --git a/tests/test_series.py b/tests/test_series.py index c51d759f5..22db3973c 100644 --- a/tests/test_series.py +++ b/tests/test_series.py @@ -227,8 +227,9 @@ def test_types_sort_index_with_key() -> None: def test_types_sort_values() -> None: s = pd.Series([4, 2, 1, 3]) check(assert_type(s.sort_values(), pd.Series), pd.Series) - with pytest.warns(FutureWarning, match="In a future version of pandas"): - check(assert_type(s.sort_values(0), pd.Series), pd.Series) + if TYPE_CHECKING_INVALID_USAGE: + check(assert_type(s.sort_values(0), pd.Series), pd.Series) # type: ignore[assert-type,call-overload] + check(assert_type(s.sort_values(axis=0), pd.Series), pd.Series) check(assert_type(s.sort_values(ascending=False), pd.Series), pd.Series) assert assert_type(s.sort_values(inplace=True, kind="quicksort"), None) is None check(assert_type(s.sort_values(na_position="last"), pd.Series), pd.Series) @@ -491,8 +492,9 @@ def test_types_plot() -> None: def test_types_window() -> None: s = pd.Series([0, 1, 1, 0, 5, 1, -10]) s.expanding() - with pytest.warns(FutureWarning, match="The `center` argument"): - s.expanding(axis=0, center=True) + s.expanding(axis=0) + if TYPE_CHECKING_INVALID_USAGE: + s.expanding(axis=0, center=True) # type: ignore[call-arg] s.rolling(2) s.rolling(2, axis=0, center=True) diff --git a/tests/test_testing.py b/tests/test_testing.py index 14daacdce..77fb62592 100644 --- a/tests/test_testing.py +++ b/tests/test_testing.py @@ -8,10 +8,12 @@ assert_frame_equal, assert_series_equal, ) -import pytest from typing_extensions import assert_type -from tests import check +from tests import ( + TYPE_CHECKING_INVALID_USAGE, + check, +) def test_types_assert_series_equal() -> None: @@ -26,9 +28,13 @@ def test_types_assert_series_equal() -> None: check_flags=True, check_datetimelike_compat=True, ) - with pytest.warns(FutureWarning, match="The 'check_less_precise'"): + if TYPE_CHECKING_INVALID_USAGE: assert_series_equal( - s1, s2, check_dtype=True, check_less_precise=True, check_names=True + s1, + s2, + check_dtype=True, + check_less_precise=True, # type: ignore[call-arg] + check_names=True, )