diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 60814145..8ea1c32f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,7 @@ repos: hooks: - id: isort - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.11.5 + rev: v0.11.13 hooks: - id: ruff args: [ diff --git a/pyproject.toml b/pyproject.toml index 4b879f2f..a78d5df0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,7 +37,7 @@ ty = "^0.0.1a8" [tool.poetry.group.dev.dependencies] mypy = "1.16.0" -pandas = "2.2.3" +pandas = "2.3.0" pyarrow = ">=10.0.1" pytest = ">=7.1.2" pyright = ">=1.1.400" diff --git a/tests/__init__.py b/tests/__init__.py index 7b5c93b5..e0682a2d 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -50,7 +50,7 @@ TYPE_CHECKING_INVALID_USAGE: Final = TYPE_CHECKING WINDOWS = os.name == "nt" or "cygwin" in platform.system().lower() -PD_LTE_22 = Version(pd.__version__) < Version("2.2.999") +PD_LTE_23 = Version(pd.__version__) < Version("2.3.999") NUMPY20 = np.lib.NumpyVersion(np.__version__) >= "2.0.0" diff --git a/tests/test_errors.py b/tests/test_errors.py index 1da52167..a6762405 100644 --- a/tests/test_errors.py +++ b/tests/test_errors.py @@ -4,7 +4,7 @@ import pytest from tests import ( - PD_LTE_22, + PD_LTE_23, WINDOWS, ) @@ -108,13 +108,13 @@ def test_specification_error() -> None: def test_setting_with_copy_error() -> None: - if PD_LTE_22: + if PD_LTE_23: with pytest.raises(errors.SettingWithCopyError): raise errors.SettingWithCopyError() def test_setting_with_copy_warning() -> None: - if PD_LTE_22: + if PD_LTE_23: with pytest.warns(errors.SettingWithCopyWarning): warnings.warn("", errors.SettingWithCopyWarning) diff --git a/tests/test_frame.py b/tests/test_frame.py index 339e6e2b..eb0da931 100644 --- a/tests/test_frame.py +++ b/tests/test_frame.py @@ -48,7 +48,7 @@ from pandas._typing import Scalar from tests import ( - PD_LTE_22, + PD_LTE_23, TYPE_CHECKING_INVALID_USAGE, check, ensure_clean, @@ -450,7 +450,7 @@ def test_types_drop_duplicates() -> None: pd.DataFrame, ) - if not PD_LTE_22: + if not PD_LTE_23: check(assert_type(df.drop_duplicates({"AAA"}), pd.DataFrame), pd.DataFrame) check( assert_type(df.drop_duplicates({"AAA": None}), pd.DataFrame), pd.DataFrame @@ -1544,14 +1544,14 @@ def test_types_groupby() -> None: with pytest_warns_bounded( FutureWarning, "(The provided callable is currently using|The behavior of DataFrame.sum with)", - upper="2.2.99", + upper="2.3.99", ): with pytest_warns_bounded( - DeprecationWarning, + FutureWarning, "DataFrameGroupBy.apply operated on the grouping columns", - upper="2.2.99", + upper="2.3.99", ): - if PD_LTE_22: + if PD_LTE_23: check( assert_type(df.groupby(by="col1").apply(sum), pd.DataFrame), pd.DataFrame, @@ -1602,7 +1602,7 @@ def wrapped_min(x: Any) -> Any: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using", - upper="2.2.99", + upper="2.3.99", ): check(assert_type(df.groupby("col1")["col3"].agg(min), pd.Series), pd.Series) check( @@ -1751,7 +1751,7 @@ def test_types_window() -> None: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using", - upper="2.2.99", + upper="2.3.99", ): check( assert_type(df.rolling(2).agg(max), pd.DataFrame), @@ -1860,7 +1860,7 @@ def test_types_agg() -> None: with pytest_warns_bounded( FutureWarning, r"The provided callable <(built-in function (min|max|mean)|function mean at 0x\w+)> is currently using", - upper="2.2.99", + upper="2.3.99", ): check(assert_type(df.agg(min), pd.Series), pd.Series) check(assert_type(df.agg([min, max]), pd.DataFrame), pd.DataFrame) @@ -1887,7 +1887,7 @@ def test_types_aggregate() -> None: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using", - upper="2.2.99", + upper="2.3.99", ): check(assert_type(df.aggregate(min), pd.Series), pd.Series) check(assert_type(df.aggregate([min, max]), pd.DataFrame), pd.DataFrame) @@ -2020,7 +2020,7 @@ def test_types_resample() -> None: FutureWarning, "'M' is deprecated", lower="2.1.99", - upper="2.2.99", + upper="2.3.99", upper_exception=ValueError, ): df.resample("M", on="date") @@ -2163,7 +2163,7 @@ def resampler_foo(resampler: Resampler[pd.DataFrame]) -> pd.DataFrame: FutureWarning, "'M' is deprecated", lower="2.1.99", - upper="2.2.99", + upper="2.3.99", upper_exception=ValueError, ): ( @@ -2504,7 +2504,7 @@ def test_types_regressions() -> None: tslist = list(pd.to_datetime(["2022-01-01", "2022-01-02"])) check(assert_type(tslist, list[pd.Timestamp]), list, pd.Timestamp) sseries = pd.Series(tslist) - with pytest_warns_bounded(FutureWarning, "'d' is deprecated", lower="2.2.99"): + with pytest_warns_bounded(FutureWarning, "'d' is deprecated", lower="2.3.99"): sseries + pd.Timedelta(1, "d") check( @@ -2518,7 +2518,7 @@ def test_types_regressions() -> None: FutureWarning, "'H' is deprecated", lower="2.1.99", - upper="2.2.99", + upper="2.3.99", upper_exception=ValueError, ): pd.date_range(start="2021-12-01", periods=24, freq="H") @@ -2644,7 +2644,7 @@ class ReadCsvKwargs(TypedDict): ), pd.DataFrame, ) - if PD_LTE_22: + if PD_LTE_23: parse_dates_2 = {"combined_date": ["Year", "Month", "Day"]} with pytest_warns_bounded( FutureWarning, @@ -3098,7 +3098,7 @@ def test_frame_stack() -> None: with pytest_warns_bounded( FutureWarning, "The previous implementation of stack is deprecated", - upper="2.2.99", + upper="2.3.99", ): check( assert_type( @@ -3113,7 +3113,7 @@ def test_frame_stack() -> None: ), pd.Series, ) - if PD_LTE_22: + if PD_LTE_23: check( assert_type( df_multi_level_cols2.stack(0, future_stack=False), @@ -3133,19 +3133,17 @@ def test_frame_stack() -> None: def test_frame_reindex() -> None: # GH 84 df = pd.DataFrame({"a": [1, 2, 3]}, index=[0, 1, 2]) - df.reindex([2, 1, 0]) + check(assert_type(df.reindex([2, 1, 0]), pd.DataFrame), pd.DataFrame) def test_frame_reindex_like() -> None: # GH 84 df = pd.DataFrame({"a": [1, 2, 3]}, index=[0, 1, 2]) other = pd.DataFrame({"a": [1, 2]}, index=[1, 0]) - with pytest_warns_bounded( FutureWarning, "the 'method' keyword is deprecated and will be removed in a future version. Please take steps to stop the use of 'method'", - lower="2.2.99", - upper="3.0.99", + lower="2.3.0", ): check( assert_type( @@ -3277,7 +3275,7 @@ def test_groupby_result() -> None: index, value = next(iterator) assert_type((index, value), tuple[tuple, pd.DataFrame]) - if PD_LTE_22: + if PD_LTE_23: check(assert_type(index, tuple), tuple, np.integer) else: check(assert_type(index, tuple), tuple, int) @@ -3389,7 +3387,7 @@ def test_groupby_result_for_ambiguous_indexes() -> None: with pytest_warns_bounded( FutureWarning, "The default of observed=False is deprecated", - upper="2.2.99", + upper="2.3.99", ): categorical_index = pd.CategoricalIndex(df.a) iterator2 = df.groupby(categorical_index).__iter__() @@ -3449,8 +3447,9 @@ def sum_mean(x: pd.DataFrame) -> float: return x.sum().mean() with pytest_warns_bounded( - DeprecationWarning, + FutureWarning, "DataFrameGroupBy.apply operated on the grouping columns.", + lower="2.2.99", upper="2.99", ): check( @@ -3460,8 +3459,9 @@ def sum_mean(x: pd.DataFrame) -> float: lfunc: Callable[[pd.DataFrame], float] = lambda x: x.sum().mean() with pytest_warns_bounded( - DeprecationWarning, + FutureWarning, "DataFrameGroupBy.apply operated on the grouping columns.", + lower="2.2.99", upper="2.99", ): check(assert_type(df.groupby("col1").apply(lfunc), pd.Series), pd.Series) @@ -3470,8 +3470,9 @@ def sum_to_list(x: pd.DataFrame) -> list: return x.sum().tolist() with pytest_warns_bounded( - DeprecationWarning, + FutureWarning, "DataFrameGroupBy.apply operated on the grouping columns.", + lower="2.2.99", upper="2.99", ): check(assert_type(df.groupby("col1").apply(sum_to_list), pd.Series), pd.Series) @@ -3480,8 +3481,9 @@ def sum_to_series(x: pd.DataFrame) -> pd.Series: return x.sum() with pytest_warns_bounded( - DeprecationWarning, + FutureWarning, "DataFrameGroupBy.apply operated on the grouping columns.", + lower="2.2.99", upper="2.99", ): check( @@ -3493,8 +3495,9 @@ def sample_to_df(x: pd.DataFrame) -> pd.DataFrame: return x.sample() with pytest_warns_bounded( - DeprecationWarning, + FutureWarning, "DataFrameGroupBy.apply operated on the grouping columns.", + lower="2.2.99", upper="2.99", ): check( @@ -3769,7 +3772,7 @@ def test_resample_150_changes() -> None: FutureWarning, "'M' is deprecated", lower="2.1.99", - upper="2.2.99", + upper="2.99", upper_exception=ValueError, ): frame.resample("M", group_keys=True) @@ -3872,7 +3875,7 @@ def test_getattr_and_dataframe_groupby() -> None: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using", - upper="2.2.99", + upper="2.3.99", ): check(assert_type(df.groupby("col1").col3.agg(min), pd.Series), pd.Series) check( @@ -4384,12 +4387,11 @@ def test_transpose() -> None: df = pd.DataFrame({"a": [1, 1, 2], "b": [4, 5, 6]}) check(assert_type(df.transpose(), pd.DataFrame), pd.DataFrame) check(assert_type(df.transpose(None), pd.DataFrame), pd.DataFrame) - msg = "The copy keyword is deprecated and will be removed in a future" with pytest_warns_bounded( DeprecationWarning, msg, - lower="2.2.99", + lower="2.3.99", ): check(assert_type(df.transpose(copy=True), pd.DataFrame), pd.DataFrame) diff --git a/tests/test_groupby.py b/tests/test_groupby.py index 533b577e..cc81feb0 100644 --- a/tests/test_groupby.py +++ b/tests/test_groupby.py @@ -34,7 +34,7 @@ from typing_extensions import assert_type from tests import ( - PD_LTE_22, + PD_LTE_23, TYPE_CHECKING_INVALID_USAGE, check, pytest_warns_bounded, @@ -78,8 +78,9 @@ def test_frame_groupby_resample() -> None: # agg funcs with pytest_warns_bounded( - DeprecationWarning, + FutureWarning, "DataFrameGroupBy.(apply|resample) operated on the grouping columns", + lower="2.2.99", upper="2.99", ): check(assert_type(GB_DF.resample("ME").sum(), DataFrame), DataFrame) @@ -125,14 +126,15 @@ def test_frame_groupby_resample() -> None: # aggregate / apply with pytest_warns_bounded( - DeprecationWarning, + FutureWarning, "DataFrameGroupBy.(apply|resample) operated on the grouping columns", + lower="2.2.99", upper="2.99", ): with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using ", - upper="2.2.99", + upper="2.99", ): check( assert_type(GB_DF.resample("ME").aggregate(np.sum), DataFrame), @@ -173,8 +175,9 @@ def f(val: DataFrame) -> Series: return val.mean() with pytest_warns_bounded( - DeprecationWarning, + FutureWarning, "DataFrameGroupBy.(apply|resample) operated on the grouping columns", + lower="2.2.99", upper="2.99", ): check(assert_type(GB_DF.resample("ME").aggregate(f), DataFrame), DataFrame) @@ -190,14 +193,15 @@ def df2scalar(val: DataFrame) -> float: return float(val.mean().mean()) with pytest_warns_bounded( - DeprecationWarning, + FutureWarning, "DataFrameGroupBy.(apply|resample) operated on the grouping columns", + lower="2.2.99", upper="2.99", ): with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using ", - upper="2.2.99", + upper="2.99", ): check(GB_DF.resample("ME").aggregate(np.sum), DataFrame) check(GB_DF.resample("ME").aggregate([np.mean]), DataFrame) @@ -250,7 +254,7 @@ def df2scalar(val: DataFrame) -> float: ) # interpolate - if PD_LTE_22: + if PD_LTE_23: check(assert_type(GB_DF.resample("ME").interpolate(), DataFrame), DataFrame) check( assert_type( @@ -377,7 +381,7 @@ def test_series_groupby_resample() -> None: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using ", - upper="2.2.99", + upper="2.99", ): check( assert_type( @@ -426,7 +430,7 @@ def f(val: Series) -> float: check(assert_type(GB_S.resample("ME").asfreq(-1.0), "Series[float]"), Series, float) # interpolate - if PD_LTE_22: + if PD_LTE_23: check( assert_type(GB_S.resample("ME").interpolate(), "Series[float]"), Series, @@ -475,7 +479,7 @@ def s2scalar(val: Series) -> float: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using ", - upper="2.2.99", + upper="2.99", ): check(GB_S.resample("ME").aggregate(np.sum), Series) check(GB_S.resample("ME").aggregate([np.mean]), DataFrame) @@ -501,7 +505,7 @@ def test_frame_groupby_rolling() -> None: check(assert_type(GB_DF.rolling(1).obj, DataFrame), DataFrame) check(assert_type(GB_DF.rolling(1).on, Union[str, Index, None]), type(None)) check(assert_type(GB_DF.rolling(1).method, Literal["single", "table"]), str) - if PD_LTE_22: + if PD_LTE_23: check(assert_type(GB_DF.rolling(1).axis, int), int) # agg funcs @@ -522,7 +526,7 @@ def test_frame_groupby_rolling() -> None: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using ", - upper="2.2.99", + upper="2.99", ): check(assert_type(GB_DF.rolling(1).aggregate(np.sum), DataFrame), DataFrame) check(assert_type(GB_DF.rolling(1).agg(np.sum), DataFrame), DataFrame) @@ -566,7 +570,7 @@ def df2scalar(val: DataFrame) -> float: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using ", - upper="2.2.99", + upper="2.99", ): check(GB_DF.rolling(1).aggregate(np.sum), DataFrame) check(GB_DF.rolling(1).aggregate([np.mean]), DataFrame) @@ -644,7 +648,7 @@ def test_series_groupby_rolling() -> None: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using ", - upper="2.2.99", + upper="2.99", ): check(assert_type(GB_S.rolling(1).aggregate("sum"), Series), Series) check(assert_type(GB_S.rolling(1).aggregate(np.sum), Series), Series) @@ -696,7 +700,7 @@ def test_frame_groupby_expanding() -> None: check(assert_type(GB_DF.expanding(1).obj, DataFrame), DataFrame) check(assert_type(GB_DF.expanding(1).on, Union[str, Index, None]), type(None)) check(assert_type(GB_DF.expanding(1).method, Literal["single", "table"]), str) - if PD_LTE_22: + if PD_LTE_23: check(assert_type(GB_DF.expanding(1).axis, int), int) # agg funcs @@ -717,7 +721,7 @@ def test_frame_groupby_expanding() -> None: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using ", - upper="2.2.99", + upper="2.99", ): check(assert_type(GB_DF.expanding(1).aggregate(np.sum), DataFrame), DataFrame) check(assert_type(GB_DF.expanding(1).agg(np.sum), DataFrame), DataFrame) @@ -763,7 +767,7 @@ def df2scalar(val: DataFrame) -> float: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using ", - upper="2.2.99", + upper="2.99", ): check(GB_DF.expanding(1).aggregate(np.sum), DataFrame) check(GB_DF.expanding(1).aggregate([np.mean]), DataFrame) @@ -843,7 +847,7 @@ def test_series_groupby_expanding() -> None: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using ", - upper="2.2.99", + upper="2.99", ): check(assert_type(GB_S.expanding(1).aggregate("sum"), Series), Series) check(assert_type(GB_S.expanding(1).aggregate(np.sum), Series), Series) @@ -895,7 +899,7 @@ def test_frame_groupby_ewm() -> None: check(assert_type(GB_DF.ewm(1).obj, DataFrame), DataFrame) check(assert_type(GB_DF.ewm(1).on, Union[str, Index, None]), type(None)) check(assert_type(GB_DF.ewm(1).method, Literal["single", "table"]), str) - if PD_LTE_22: + if PD_LTE_23: check(assert_type(GB_DF.ewm(1).axis, int), int) # agg funcs @@ -908,11 +912,11 @@ def test_frame_groupby_ewm() -> None: check(assert_type(GB_DF.ewm(1).var(), DataFrame), DataFrame) # aggregate - if PD_LTE_22: + if PD_LTE_23: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using ", - upper="2.2.99", + upper="2.99", ): check(assert_type(GB_DF.ewm(1).aggregate(np.sum), DataFrame), DataFrame) check(assert_type(GB_DF.ewm(1).agg(np.sum), DataFrame), DataFrame) @@ -943,7 +947,7 @@ def test_frame_groupby_ewm() -> None: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using ", - upper="2.2.99", + upper="2.99", ): check(GB_DF.ewm(1).aggregate(np.sum), DataFrame) check(GB_DF.ewm(1).aggregate([np.mean]), DataFrame) @@ -1016,10 +1020,10 @@ def test_series_groupby_ewm() -> None: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using ", - upper="2.2.99", + upper="2.99", ): check(assert_type(GB_S.ewm(1).aggregate("sum"), Series), Series) - if PD_LTE_22: + if PD_LTE_23: check(assert_type(GB_S.ewm(1).aggregate(np.sum), Series), Series) check(assert_type(GB_S.ewm(1).agg(np.sum), Series), Series) check( diff --git a/tests/test_indexes.py b/tests/test_indexes.py index feea7535..14bbc762 100644 --- a/tests/test_indexes.py +++ b/tests/test_indexes.py @@ -20,7 +20,7 @@ from tests import Dtype # noqa: F401 from tests import ( - PD_LTE_22, + PD_LTE_23, TYPE_CHECKING_INVALID_USAGE, check, pytest_warns_bounded, @@ -356,7 +356,7 @@ def test_interval_range(): FutureWarning, "'M' is deprecated", lower="2.1.99", - upper="2.2.99", + upper="2.3.99", upper_exception=ValueError, ): check( @@ -680,7 +680,7 @@ def test_interval_index_arrays(): FutureWarning, "'Y' is deprecated", lower="2.1.99", - upper="2.2.99", + upper="2.3.99", upper_exception=ValueError, ): pd.Series(pd.date_range("2000-01-01", "2003-01-01", freq="Y")) @@ -984,7 +984,7 @@ def test_getitem() -> None: check( assert_type(iri[[0, 2, 4]], pd.Index), pd.Index, - np.integer if PD_LTE_22 else int, + np.integer if PD_LTE_23 else int, ) mi = pd.MultiIndex.from_product([["a", "b"], ["c", "d"]], names=["ab", "cd"]) @@ -1123,7 +1123,7 @@ def test_iter() -> None: FutureWarning, "'H' is deprecated", lower="2.1.99", - upper="2.2.99", + upper="2.3.99", upper_exception=ValueError, ): for ts in pd.date_range(start="1/1/2023", end="1/08/2023", freq="6H"): diff --git a/tests/test_pandas.py b/tests/test_pandas.py index b9ff22c8..068254c3 100644 --- a/tests/test_pandas.py +++ b/tests/test_pandas.py @@ -30,7 +30,7 @@ from pandas._typing import Scalar from tests import ( - PD_LTE_22, + PD_LTE_23, TYPE_CHECKING_INVALID_USAGE, check, pytest_warns_bounded, @@ -293,7 +293,7 @@ def test_concat_args() -> None: with pytest_warns_bounded( DeprecationWarning, "The copy keyword is deprecated and will be removed in a future version.", - lower="2.2.99", + lower="2.3.99", ): check(assert_type(pd.concat([df, df2], copy=True), pd.DataFrame), pd.DataFrame) check(assert_type(pd.concat([df, df2], join="inner"), pd.DataFrame), pd.DataFrame) @@ -560,11 +560,11 @@ def test_unique() -> None: ) check( assert_type(pd.unique(pd.Index(["a", "b", "c", "a"])), np.ndarray), - np.ndarray if PD_LTE_22 else pd.Index, + np.ndarray if PD_LTE_23 else pd.Index, ) check( assert_type(pd.unique(pd.RangeIndex(0, 10)), np.ndarray), - np.ndarray if PD_LTE_22 else pd.Index, + np.ndarray if PD_LTE_23 else pd.Index, ) check( assert_type(pd.unique(pd.Categorical(["a", "b", "c", "a"])), pd.Categorical), @@ -582,7 +582,7 @@ def test_unique() -> None: pd.unique(pd.timedelta_range(start="1 day", periods=4)), np.ndarray, ), - np.ndarray if PD_LTE_22 else pd.Index, + np.ndarray if PD_LTE_23 else pd.Index, ) @@ -900,15 +900,15 @@ def test_index_unqiue() -> None: check(assert_type(pd.unique(ci), pd.CategoricalIndex), pd.CategoricalIndex) check( - assert_type(pd.unique(dti), np.ndarray), np.ndarray if PD_LTE_22 else pd.Index + assert_type(pd.unique(dti), np.ndarray), np.ndarray if PD_LTE_23 else pd.Index ) - check(assert_type(pd.unique(i), np.ndarray), np.ndarray if PD_LTE_22 else pd.Index) + check(assert_type(pd.unique(i), np.ndarray), np.ndarray if PD_LTE_23 else pd.Index) check(assert_type(pd.unique(pi), pd.PeriodIndex), pd.PeriodIndex) - check(assert_type(pd.unique(ri), np.ndarray), np.ndarray if PD_LTE_22 else pd.Index) + check(assert_type(pd.unique(ri), np.ndarray), np.ndarray if PD_LTE_23 else pd.Index) check( - assert_type(pd.unique(tdi), np.ndarray), np.ndarray if PD_LTE_22 else pd.Index + assert_type(pd.unique(tdi), np.ndarray), np.ndarray if PD_LTE_23 else pd.Index ) - check(assert_type(pd.unique(mi), np.ndarray), np.ndarray if PD_LTE_22 else pd.Index) + check(assert_type(pd.unique(mi), np.ndarray), np.ndarray if PD_LTE_23 else pd.Index) check( assert_type(pd.unique(interval_i), "pd.IntervalIndex[pd.Interval[int]]"), pd.IntervalIndex, @@ -1588,7 +1588,7 @@ def test_crosstab_args() -> None: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using", - upper="2.2.99", + upper="2.3.99", ): check( assert_type(pd.crosstab(a, b, values=values, aggfunc=np.sum), pd.DataFrame), @@ -1816,7 +1816,7 @@ def test_pivot_table() -> None: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using", - upper="2.2.99", + upper="2.3.99", ): check( assert_type( @@ -1852,7 +1852,7 @@ def test_pivot_table() -> None: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using", - upper="2.2.99", + upper="2.3.99", ): check( assert_type( @@ -1920,7 +1920,7 @@ def g(x: pd.Series) -> int: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using", - upper="2.2.99", + upper="2.3.99", ): check( assert_type( @@ -1947,7 +1947,7 @@ def g(x: pd.Series) -> int: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using", - upper="2.2.99", + upper="2.3.99", ): check( assert_type( @@ -2048,7 +2048,7 @@ def g(x: pd.Series) -> int: FutureWarning, "'M' is deprecated", lower="2.1.99", - upper="2.2.99", + upper="2.3.99", upper_exception=ValueError, ): check( @@ -2064,7 +2064,7 @@ def g(x: pd.Series) -> int: FutureWarning, "'(M|A)' is deprecated", lower="2.1.99", - upper="2.2.99", + upper="2.3.99", upper_exception=ValueError, ): check( diff --git a/tests/test_plotting.py b/tests/test_plotting.py index d89cab3c..82112dea 100644 --- a/tests/test_plotting.py +++ b/tests/test_plotting.py @@ -17,7 +17,7 @@ from typing_extensions import assert_type from tests import ( - PD_LTE_22, + PD_LTE_23, check, ) @@ -609,7 +609,7 @@ def test_grouped_dataframe_boxplot(close_figures): check(assert_type(grouped.boxplot(subplots=True), Series), Series) # a single plot - if not PD_LTE_22: + if not PD_LTE_23: check( assert_type( grouped.boxplot( @@ -654,7 +654,7 @@ def test_grouped_dataframe_boxplot_single(close_figures): Axes, ) - if not PD_LTE_22: + if not PD_LTE_23: check( assert_type( grouped.boxplot( diff --git a/tests/test_resampler.py b/tests/test_resampler.py index 1bef9af3..c79f55f1 100644 --- a/tests/test_resampler.py +++ b/tests/test_resampler.py @@ -21,7 +21,7 @@ from typing_extensions import assert_type from tests import ( - PD_LTE_22, + PD_LTE_23, TYPE_CHECKING_INVALID_USAGE, check, pytest_warns_bounded, @@ -96,7 +96,7 @@ def test_aggregate() -> None: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using ", - upper="2.2.99", + upper="2.3.99", ): check(assert_type(DF.resample("ME").aggregate(np.sum), DataFrame), DataFrame) check(assert_type(DF.resample("ME").agg(np.sum), DataFrame), DataFrame) @@ -149,7 +149,7 @@ def test_interpolate() -> None: def test_interpolate_inplace() -> None: - if PD_LTE_22: + if PD_LTE_23: # Bug in main see https://github.com/pandas-dev/pandas/issues/58690 check( assert_type(DF.resample("ME").interpolate(inplace=True), None), type(None) @@ -328,7 +328,7 @@ def test_aggregate_series() -> None: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using ", - upper="2.2.99", + upper="2.3.99", ): check(assert_type(S.resample("ME").aggregate(np.sum), _AggRetType), Series) check(assert_type(S.resample("ME").agg(np.sum), _AggRetType), Series) @@ -365,7 +365,7 @@ def test_interpolate_series() -> None: def test_interpolate_inplace_series() -> None: - if PD_LTE_22: + if PD_LTE_23: # Bug in main see https://github.com/pandas-dev/pandas/issues/58690 check(assert_type(S.resample("ME").interpolate(inplace=True), None), type(None)) @@ -407,7 +407,7 @@ def s2scalar(val: Series) -> float: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using ", - upper="2.2.99", + upper="2.3.99", ): check(S.resample("ME").aggregate(np.sum), Series) check(S.resample("ME").aggregate([np.mean]), DataFrame) @@ -432,7 +432,7 @@ def df2scalar(val: DataFrame) -> float: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using ", - upper="2.2.99", + upper="2.3.99", ): check(DF.resample("ME").aggregate(np.sum), DataFrame) check(DF.resample("ME").aggregate([np.mean]), DataFrame) diff --git a/tests/test_scalars.py b/tests/test_scalars.py index 3d8125e9..bfc78ae6 100644 --- a/tests/test_scalars.py +++ b/tests/test_scalars.py @@ -386,10 +386,10 @@ def test_interval_cmp(): def test_timedelta_construction() -> None: check(assert_type(pd.Timedelta(1, "W"), pd.Timedelta), pd.Timedelta) - with pytest_warns_bounded(FutureWarning, "'w' is deprecated", lower="2.2.99"): + with pytest_warns_bounded(FutureWarning, "'w' is deprecated", lower="2.3.99"): check(assert_type(pd.Timedelta(1, "w"), pd.Timedelta), pd.Timedelta) check(assert_type(pd.Timedelta(1, "D"), pd.Timedelta), pd.Timedelta) - with pytest_warns_bounded(FutureWarning, "'d' is deprecated", lower="2.2.99"): + with pytest_warns_bounded(FutureWarning, "'d' is deprecated", lower="2.3.99"): check(assert_type(pd.Timedelta(1, "d"), pd.Timedelta), pd.Timedelta) check(assert_type(pd.Timedelta(1, "days"), pd.Timedelta), pd.Timedelta) check(assert_type(pd.Timedelta(1, "day"), pd.Timedelta), pd.Timedelta) @@ -423,10 +423,10 @@ def test_timedelta_construction() -> None: check(assert_type(pd.Timedelta(1, "nanosecond"), pd.Timedelta), pd.Timedelta) check(assert_type(pd.Timedelta("1 W"), pd.Timedelta), pd.Timedelta) - with pytest_warns_bounded(FutureWarning, "'w' is deprecated", lower="2.2.99"): + with pytest_warns_bounded(FutureWarning, "'w' is deprecated", lower="2.3.99"): check(assert_type(pd.Timedelta("1 w"), pd.Timedelta), pd.Timedelta) check(assert_type(pd.Timedelta("1 D"), pd.Timedelta), pd.Timedelta) - with pytest_warns_bounded(FutureWarning, "'d' is deprecated", lower="2.2.99"): + with pytest_warns_bounded(FutureWarning, "'d' is deprecated", lower="2.3.99"): check(assert_type(pd.Timedelta("1 d"), pd.Timedelta), pd.Timedelta) check(assert_type(pd.Timedelta("1 days"), pd.Timedelta), pd.Timedelta) check(assert_type(pd.Timedelta("1 day"), pd.Timedelta), pd.Timedelta) @@ -1573,7 +1573,7 @@ def test_timestamp_misc_methods() -> None: FutureWarning, "'H' is deprecated ", lower="2.1.99", - upper="2.2.99", + upper="2.3.99", upper_exception=ValueError, ): check( @@ -1614,7 +1614,7 @@ def test_timestamp_misc_methods() -> None: FutureWarning, "'H' is deprecated", lower="2.1.99", - upper="2.2.99", + upper="2.3.99", upper_exception=ValueError, ): check( @@ -1654,7 +1654,7 @@ def test_timestamp_misc_methods() -> None: FutureWarning, "'H' is deprecated", lower="2.1.99", - upper="2.2.99", + upper="2.3.99", upper_exception=ValueError, ): check( diff --git a/tests/test_series.py b/tests/test_series.py index 57051997..68cb9a15 100644 --- a/tests/test_series.py +++ b/tests/test_series.py @@ -49,7 +49,7 @@ ) from tests import ( - PD_LTE_22, + PD_LTE_23, TYPE_CHECKING_INVALID_USAGE, WINDOWS, check, @@ -186,7 +186,7 @@ def test_types_copy() -> None: def test_types_select() -> None: s = pd.Series(data={"row1": 1, "row2": 2}) - if PD_LTE_22: + if PD_LTE_23: # Not valid in 3.0 with pytest_warns_bounded( FutureWarning, @@ -926,7 +926,7 @@ def test_groupby_result() -> None: index, value = next(iterator) assert_type((index, value), tuple[tuple, "pd.Series[int]"]) - if PD_LTE_22: + if PD_LTE_23: check(assert_type(index, tuple), tuple, np.integer) else: check(assert_type(index, tuple), tuple, int) @@ -1055,7 +1055,7 @@ def test_groupby_result_for_ambiguous_indexes() -> None: with pytest_warns_bounded( FutureWarning, "The default of observed=False is deprecated", - upper="2.2.99", + upper="2.3.99", ): categorical_index = pd.CategoricalIndex(s.index) iterator2 = s.groupby(categorical_index).__iter__() @@ -1076,7 +1076,7 @@ def test_types_groupby_agg() -> None: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using", - upper="2.2.99", + upper="2.3.99", ): check(assert_type(s.groupby(level=0).agg(sum), pd.Series), pd.Series) check( @@ -1094,7 +1094,7 @@ def test_types_groupby_aggregate() -> None: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using", - upper="2.2.99", + upper="2.3.99", ): check(assert_type(s.groupby(level=0).aggregate(sum), pd.Series), pd.Series) check( @@ -1150,7 +1150,7 @@ def test_types_window() -> None: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using", - upper="2.2.99", + upper="2.3.99", ): check( assert_type(s.rolling(2).agg(sum), pd.Series), @@ -1220,9 +1220,9 @@ def test_types_agg() -> None: with pytest_warns_bounded( FutureWarning, r"The provided callable <(built-in function (min|max|mean)|function mean at 0x\w+)> is currently using", - upper="2.2.99", + upper="2.3.99", ): - check(assert_type(s.agg(min), int), np.integer if PD_LTE_22 else int) + check(assert_type(s.agg(min), int), np.integer if PD_LTE_23 else int) check(assert_type(s.agg([min, max]), pd.Series), pd.Series, np.integer) check(assert_type(s.agg({0: min}), pd.Series), pd.Series, np.integer) check( @@ -1244,9 +1244,9 @@ def test_types_aggregate() -> None: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using", - upper="2.2.99", + upper="2.3.99", ): - check(assert_type(s.aggregate(min), int), np.integer if PD_LTE_22 else int) + check(assert_type(s.aggregate(min), int), np.integer if PD_LTE_23 else int) check( assert_type(s.aggregate([min, max]), pd.Series), pd.Series, @@ -1972,7 +1972,7 @@ def test_bitwise_operators() -> None: check(assert_type(s ^ s2, "pd.Series[int]"), pd.Series, np.integer) check(assert_type(s2 ^ s, "pd.Series[int]"), pd.Series, np.integer) - if PD_LTE_22: + if PD_LTE_23: with pytest_warns_bounded( FutureWarning, r"Logical ops \(and, or, xor\) between Pandas objects and dtype-less sequences " @@ -2020,7 +2020,7 @@ def test_logical_operators() -> None: check(assert_type(True ^ (df["a"] >= 2), "pd.Series[bool]"), pd.Series, np.bool_) - if PD_LTE_22: + if PD_LTE_23: with pytest_warns_bounded( FutureWarning, r"Logical ops \(and, or, xor\) between Pandas objects and dtype-less sequences " @@ -3752,7 +3752,7 @@ def test_series_reindex_like() -> None: with pytest_warns_bounded( FutureWarning, "the 'method' keyword is deprecated and will be removed in a future version. Please take steps to stop the use of 'method'", - lower="2.2.99", + lower="2.3.99", upper="3.0.99", ): check( @@ -3791,7 +3791,7 @@ def test_align() -> None: with pytest_warns_bounded( DeprecationWarning, msg, - lower="2.2.99", + lower="2.3.99", ): aligned_s0, aligned_s1 = s0.align(s1, fill_value=0, axis=0, level=0, copy=False) diff --git a/tests/test_timefuncs.py b/tests/test_timefuncs.py index 6f009256..de6a6e64 100644 --- a/tests/test_timefuncs.py +++ b/tests/test_timefuncs.py @@ -30,7 +30,7 @@ from pandas._typing import TimeUnit from tests import ( - PD_LTE_22, + PD_LTE_23, TYPE_CHECKING_INVALID_USAGE, check, pytest_warns_bounded, @@ -416,11 +416,11 @@ def test_series_dt_accessors() -> None: with pytest_warns_bounded( FutureWarning, "The behavior of DatetimeProperties.to_pydatetime is deprecated", - upper="2.2.99", + upper="2.3.99", ): check( assert_type(s0.dt.to_pydatetime(), np.ndarray), - np.ndarray if PD_LTE_22 else pd.Series, + np.ndarray if PD_LTE_23 else pd.Series, dt.datetime, ) s0_local = s0.dt.tz_localize("UTC") @@ -541,7 +541,7 @@ def test_series_dt_accessors() -> None: with pytest_warns_bounded( FutureWarning, "The behavior of TimedeltaProperties.to_pytimedelta is deprecated", - lower="2.2.99", + lower="2.3.99", ): check(assert_type(s2.dt.to_pytimedelta(), np.ndarray), np.ndarray) check(assert_type(s2.dt.total_seconds(), "pd.Series[float]"), pd.Series, float) @@ -867,10 +867,10 @@ def test_types_to_numpy() -> None: def test_to_timedelta_units() -> None: check(assert_type(pd.to_timedelta(1, "W"), pd.Timedelta), pd.Timedelta) - with pytest_warns_bounded(FutureWarning, "'w' is deprecated", lower="2.2.99"): + with pytest_warns_bounded(FutureWarning, "'w' is deprecated", lower="2.3.99"): check(assert_type(pd.to_timedelta(1, "w"), pd.Timedelta), pd.Timedelta) check(assert_type(pd.to_timedelta(1, "D"), pd.Timedelta), pd.Timedelta) - with pytest_warns_bounded(FutureWarning, "'d' is deprecated", lower="2.2.99"): + with pytest_warns_bounded(FutureWarning, "'d' is deprecated", lower="2.3.99"): check(assert_type(pd.to_timedelta(1, "d"), pd.Timedelta), pd.Timedelta) check(assert_type(pd.to_timedelta(1, "days"), pd.Timedelta), pd.Timedelta) check(assert_type(pd.to_timedelta(1, "day"), pd.Timedelta), pd.Timedelta) diff --git a/tests/test_windowing.py b/tests/test_windowing.py index 3186415c..df64b8d8 100644 --- a/tests/test_windowing.py +++ b/tests/test_windowing.py @@ -15,7 +15,7 @@ from typing_extensions import assert_type from tests import ( - PD_LTE_22, + PD_LTE_23, check, pytest_warns_bounded, ) @@ -101,7 +101,7 @@ def test_rolling_aggregate() -> None: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using ", - upper="2.2.99", + upper="2.3.99", ): check(assert_type(DF.rolling(10).aggregate(np.mean), DataFrame), DataFrame) check( @@ -126,7 +126,7 @@ def _mean(df: DataFrame) -> Series: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using ", - upper="2.2.99", + upper="2.3.99", ): check(assert_type(DF.rolling(10).aggregate([np.mean]), DataFrame), DataFrame) check( @@ -196,7 +196,7 @@ def _mean(s: Series) -> float: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using ", - upper="2.2.99", + upper="2.3.99", ): check(assert_type(S.rolling(10).aggregate(np.mean), Series), Series) @@ -260,7 +260,7 @@ def test_expanding_aggregate() -> None: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using ", - upper="2.2.99", + upper="2.3.99", ): check(assert_type(DF.expanding(10).aggregate(np.mean), DataFrame), DataFrame) check( @@ -314,7 +314,7 @@ def test_expanding_aggregate_series() -> None: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using ", - upper="2.2.99", + upper="2.3.99", ): check(assert_type(S.expanding(10).aggregate(np.mean), Series), Series) check( @@ -340,11 +340,11 @@ def test_ewm_basic_math() -> None: def test_ewm_aggregate() -> None: - if PD_LTE_22: + if PD_LTE_23: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using ", - upper="2.2.99", + upper="2.3.99", ): check(assert_type(DF.ewm(span=10).aggregate(np.mean), DataFrame), DataFrame) check( @@ -371,11 +371,11 @@ def test_ewm_basic_math_series() -> None: def test_ewm_aggregate_series() -> None: - if PD_LTE_22: + if PD_LTE_23: with pytest_warns_bounded( FutureWarning, r"The provided callable is currently using ", - upper="2.2.99", + upper="2.3.99", ): check(assert_type(S.ewm(span=10).aggregate(np.mean), Series), Series) check(