diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index df37abb0c..4285dd7fa 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ ci: autofix_prs: false repos: - repo: https://github.com/python/black - rev: 23.10.0 + rev: 23.11.0 hooks: - id: black - repo: https://github.com/PyCQA/isort @@ -11,7 +11,7 @@ repos: hooks: - id: isort - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.1 + rev: v0.1.6 hooks: - id: ruff args: [ diff --git a/pandas-stubs/core/indexes/multi.pyi b/pandas-stubs/core/indexes/multi.pyi index 08f221dc6..f39274d39 100644 --- a/pandas-stubs/core/indexes/multi.pyi +++ b/pandas-stubs/core/indexes/multi.pyi @@ -153,7 +153,7 @@ class MultiIndex(Index[Any]): def equals(self, other) -> bool: ... def equal_levels(self, other): ... def union(self, other, sort=...): ... - def intersection(self, other, sort: bool = ...): ... + def intersection(self, other: list | Self, sort: bool = ...): ... def difference(self, other, sort=...): ... def astype(self, dtype: DtypeArg, copy: bool = ...) -> Self: ... def insert(self, loc, item): ... diff --git a/scripts/test/__init__.py b/scripts/test/__init__.py index 9c6a47099..5ae28dc6d 100644 --- a/scripts/test/__init__.py +++ b/scripts/test/__init__.py @@ -52,9 +52,6 @@ def pytest(nightly: bool) -> None: setup_steps = [] pytest_step = _step.pytest if nightly: - pytest_step = dataclasses.replace( - _step.pytest, run=partial(_step.pytest.run, flags=()) - ) setup_steps = [_step.nightly] run_job(setup_steps + [pytest_step]) diff --git a/tests/test_api_types.py b/tests/test_api_types.py index 92ba58693..f4088692e 100644 --- a/tests/test_api_types.py +++ b/tests/test_api_types.py @@ -246,15 +246,18 @@ def test_is_integer_dtype() -> None: def test_is_interval() -> None: - check(assert_type(api.is_interval(obj), bool), bool) - check(assert_type(api.is_interval(nparr), bool), bool) - check(assert_type(api.is_interval(dtylike), bool), bool) - check(assert_type(api.is_interval(arr), bool), bool) - check( - assert_type(api.is_interval(dframe), bool), - bool, - ) - check(assert_type(api.is_interval(ind), bool), bool) + with pytest_warns_bounded( + FutureWarning, "is_interval is deprecated", lower="2.1.99" + ): + check(assert_type(api.is_interval(obj), bool), bool) + check(assert_type(api.is_interval(nparr), bool), bool) + check(assert_type(api.is_interval(dtylike), bool), bool) + check(assert_type(api.is_interval(arr), bool), bool) + check( + assert_type(api.is_interval(dframe), bool), + bool, + ) + check(assert_type(api.is_interval(ind), bool), bool) def test_is_interval_dtype() -> None: diff --git a/tests/test_frame.py b/tests/test_frame.py index e8dc8042b..cb7d373f5 100644 --- a/tests/test_frame.py +++ b/tests/test_frame.py @@ -1307,9 +1307,8 @@ def test_types_to_html() -> None: def test_types_resample() -> None: df = pd.DataFrame({"values": [2, 11, 3, 13, 14, 18, 17, 19]}) df["date"] = pd.date_range("01/01/2018", periods=8, freq="W") - with pytest_warns_bounded(UserWarning, "'M' will be deprecated", lower="2.1.99"): + with pytest_warns_bounded(FutureWarning, "'M' is deprecated", lower="2.1.99"): df.resample("M", on="date") - # origin and offset params added in 1.1.0 https://pandas.pydata.org/docs/whatsnew/v1.1.0.html df.resample("20min", origin="epoch", offset=pd.Timedelta(2, "minutes"), on="date") @@ -1352,7 +1351,7 @@ def test_pipe() -> None: def foo(df: pd.DataFrame) -> pd.DataFrame: return pd.DataFrame(df) - with pytest_warns_bounded(UserWarning, "'M' will be deprecated", lower="2.1.99"): + with pytest_warns_bounded(FutureWarning, "'M' is deprecated", lower="2.1.99"): val = ( pd.DataFrame( { @@ -1521,7 +1520,8 @@ def test_types_regressions() -> None: sseries_plus1: pd.Series = sseries + pd.Timedelta(1, "d") # https://github.com/microsoft/pylance-release/issues/2133 - dr = pd.date_range(start="2021-12-01", periods=24, freq="H") + with pytest_warns_bounded(FutureWarning, "'H' is deprecated", lower="2.1.99"): + dr = pd.date_range(start="2021-12-01", periods=24, freq="H") time = dr.strftime("%H:%M:%S") # https://github.com/microsoft/python-type-stubs/issues/115 @@ -1906,18 +1906,24 @@ def test_frame_stack() -> None: [[1.0, 2.0], [3.0, 4.0]], index=["cat", "dog"], columns=multicol2 ) - check( - assert_type( - df_multi_level_cols2.stack(0), Union[pd.DataFrame, "pd.Series[Any]"] - ), - pd.DataFrame, - ) - check( - assert_type( - df_multi_level_cols2.stack([0, 1]), Union[pd.DataFrame, "pd.Series[Any]"] - ), - pd.Series, - ) + with pytest_warns_bounded( + FutureWarning, + "The previous implementation of stack is deprecated", + lower="2.1.99", + ): + check( + assert_type( + df_multi_level_cols2.stack(0), Union[pd.DataFrame, "pd.Series[Any]"] + ), + pd.DataFrame, + ) + check( + assert_type( + df_multi_level_cols2.stack([0, 1]), + Union[pd.DataFrame, "pd.Series[Any]"], + ), + pd.Series, + ) def test_frame_reindex() -> None: @@ -2491,7 +2497,7 @@ def test_quantile_150_changes() -> None: def test_resample_150_changes() -> None: idx = pd.date_range("2020-1-1", periods=700) frame = pd.DataFrame(np.random.standard_normal((700, 1)), index=idx, columns=["a"]) - with pytest_warns_bounded(UserWarning, "'M' will be deprecated", lower="2.1.99"): + with pytest_warns_bounded(FutureWarning, "'M' is deprecated", lower="2.1.99"): resampler = frame.resample("M", group_keys=True) assert_type(resampler, "Resampler[pd.DataFrame]") @@ -2858,8 +2864,11 @@ def test_interpolate_inplace() -> None: def test_groupby_fillna_inplace() -> None: # GH 691 groupby = pd.DataFrame({"a": range(3), "b": range(3)}).groupby("a") - check(assert_type(groupby.fillna(0), pd.DataFrame), pd.DataFrame) - check(assert_type(groupby.fillna(0, inplace=False), pd.DataFrame), pd.DataFrame) + with pytest_warns_bounded( + FutureWarning, "DataFrameGroupBy.fillna is deprecated", lower="2.1.99" + ): + check(assert_type(groupby.fillna(0), pd.DataFrame), pd.DataFrame) + check(assert_type(groupby.fillna(0, inplace=False), pd.DataFrame), pd.DataFrame) if TYPE_CHECKING_INVALID_USAGE: groupby.fillna(0, inplace=True) # type: ignore[arg-type] # pyright: ignore[reportGeneralTypeIssues] diff --git a/tests/test_indexes.py b/tests/test_indexes.py index a9b6f9119..f878ba17b 100644 --- a/tests/test_indexes.py +++ b/tests/test_indexes.py @@ -252,7 +252,7 @@ def test_interval_range(): pd.IntervalIndex, pd.Interval, ) - with pytest_warns_bounded(UserWarning, "'M' will be deprecated", lower="2.1.99"): + with pytest_warns_bounded(FutureWarning, "'M' is deprecated", lower="2.1.99"): check( assert_type( pd.interval_range( @@ -570,8 +570,9 @@ def test_interval_index_arrays(): pd.IntervalIndex, pd.Interval, ) - left_s_ts = pd.Series(pd.date_range("2000-01-01", "2003-01-01", freq="Y")) - right_s_ts = pd.Series(pd.date_range("2001-01-01", "2004-01-01", freq="Y")) + with pytest_warns_bounded(FutureWarning, "'Y' is deprecated", lower="2.1.99"): + left_s_ts = pd.Series(pd.date_range("2000-01-01", "2003-01-01", freq="Y")) + right_s_ts = pd.Series(pd.date_range("2001-01-01", "2004-01-01", freq="Y")) check( assert_type( pd.IntervalIndex.from_arrays(left_s_ts, right_s_ts), @@ -968,8 +969,9 @@ def test_index_constructors(): def test_iter() -> None: # GH 723 - for ts in pd.date_range(start="1/1/2023", end="1/08/2023", freq="6H"): - check(assert_type(ts, pd.Timestamp), pd.Timestamp) + with pytest_warns_bounded(FutureWarning, "'H' is deprecated", lower="2.1.99"): + for ts in pd.date_range(start="1/1/2023", end="1/08/2023", freq="6H"): + check(assert_type(ts, pd.Timestamp), pd.Timestamp) def test_intersection() -> None: diff --git a/tests/test_io.py b/tests/test_io.py index ce570c6c4..4a46d1476 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -75,7 +75,12 @@ def test_orc(): with ensure_clean() as path: check(assert_type(DF.to_orc(path), None), type(None)) - check(assert_type(read_orc(path), DataFrame), DataFrame) + with pytest_warns_bounded( + DeprecationWarning, + "Passing a BlockManager to DataFrame is deprecated", + lower="2.1.99", + ): + check(assert_type(read_orc(path), DataFrame), DataFrame) @pytest.mark.skipif(WINDOWS, reason="ORC not available on windows") @@ -83,7 +88,12 @@ def test_orc_path(): with ensure_clean() as path: pathlib_path = Path(path) check(assert_type(DF.to_orc(pathlib_path), None), type(None)) - check(assert_type(read_orc(pathlib_path), DataFrame), DataFrame) + with pytest_warns_bounded( + DeprecationWarning, + "Passing a BlockManager to DataFrame is deprecated", + lower="2.1.99", + ): + check(assert_type(read_orc(pathlib_path), DataFrame), DataFrame) @pytest.mark.skipif(WINDOWS, reason="ORC not available on windows") @@ -93,14 +103,24 @@ def test_orc_buffer(): check(assert_type(DF.to_orc(file_w), None), type(None)) with open(path, "rb") as file_r: - check(assert_type(read_orc(file_r), DataFrame), DataFrame) + with pytest_warns_bounded( + DeprecationWarning, + "Passing a BlockManager to DataFrame is deprecated", + lower="2.1.99", + ): + check(assert_type(read_orc(file_r), DataFrame), DataFrame) @pytest.mark.skipif(WINDOWS, reason="ORC not available on windows") def test_orc_columns(): with ensure_clean() as path: check(assert_type(DF.to_orc(path, index=False), None), type(None)) - check(assert_type(read_orc(path, columns=["a"]), DataFrame), DataFrame) + with pytest_warns_bounded( + DeprecationWarning, + "Passing a BlockManager to DataFrame is deprecated", + lower="2.1.99", + ): + check(assert_type(read_orc(path, columns=["a"]), DataFrame), DataFrame) @pytest.mark.skipif(WINDOWS, reason="ORC not available on windows") @@ -524,7 +544,12 @@ def test_parquet(): with ensure_clean() as path: check(assert_type(DF.to_parquet(path), None), type(None)) check(assert_type(DF.to_parquet(), bytes), bytes) - check(assert_type(read_parquet(path), DataFrame), DataFrame) + with pytest_warns_bounded( + DeprecationWarning, + "Passing a BlockManager to DataFrame is deprecated", + lower="2.1.99", + ): + check(assert_type(read_parquet(path), DataFrame), DataFrame) def test_parquet_options(): @@ -533,18 +558,33 @@ def test_parquet_options(): assert_type(DF.to_parquet(path, compression=None, index=True), None), type(None), ) - check(assert_type(read_parquet(path), DataFrame), DataFrame) + with pytest_warns_bounded( + DeprecationWarning, + "Passing a BlockManager to DataFrame is deprecated", + lower="2.1.99", + ): + check(assert_type(read_parquet(path), DataFrame), DataFrame) def test_feather(): with ensure_clean() as path: check(assert_type(DF.to_feather(path), None), type(None)) - check(assert_type(read_feather(path), DataFrame), DataFrame) - check(assert_type(read_feather(path, columns=["a"]), DataFrame), DataFrame) + with pytest_warns_bounded( + DeprecationWarning, + "Passing a BlockManager to DataFrame is deprecated", + lower="2.1.99", + ): + check(assert_type(read_feather(path), DataFrame), DataFrame) + check(assert_type(read_feather(path, columns=["a"]), DataFrame), DataFrame) with io.BytesIO() as bio: check(assert_type(DF.to_feather(bio), None), type(None)) bio.seek(0) - check(assert_type(read_feather(bio), DataFrame), DataFrame) + with pytest_warns_bounded( + DeprecationWarning, + "Passing a BlockManager to DataFrame is deprecated", + lower="2.1.99", + ): + check(assert_type(read_feather(bio), DataFrame), DataFrame) def test_read_csv(): @@ -1394,25 +1434,42 @@ def test_all_read_without_lxml_dtype_backend() -> None: if not WINDOWS: check(assert_type(DF.to_orc(path), None), type(None)) + with pytest_warns_bounded( + DeprecationWarning, + "Passing a BlockManager to DataFrame is deprecated", + lower="2.1.99", + ): + check( + assert_type( + read_orc(path, dtype_backend="numpy_nullable"), DataFrame + ), + DataFrame, + ) + check(assert_type(DF.to_feather(path), None), type(None)) + with pytest_warns_bounded( + DeprecationWarning, + "Passing a BlockManager to DataFrame is deprecated", + lower="2.1.99", + ): check( - assert_type(read_orc(path, dtype_backend="numpy_nullable"), DataFrame), + assert_type(read_feather(path, dtype_backend="pyarrow"), DataFrame), DataFrame, ) - check(assert_type(DF.to_feather(path), None), type(None)) - check( - assert_type(read_feather(path, dtype_backend="pyarrow"), DataFrame), - DataFrame, - ) - check( - assert_type( - pd.to_numeric( - [1.0, 2.0, "blerg"], errors="ignore", dtype_backend="numpy_nullable" + with pytest_warns_bounded( + FutureWarning, "errors='ignore' is deprecated", lower="2.1.99" + ): + check( + assert_type( + pd.to_numeric( + [1.0, 2.0, "blerg"], + errors="ignore", + dtype_backend="numpy_nullable", + ), + npt.NDArray, ), - npt.NDArray, - ), - np.ndarray, - ) + np.ndarray, + ) with ensure_clean(".xlsx") as path: as_str: str = path diff --git a/tests/test_pandas.py b/tests/test_pandas.py index b709de293..cf85f2766 100644 --- a/tests/test_pandas.py +++ b/tests/test_pandas.py @@ -563,7 +563,10 @@ def test_to_numeric_scalar() -> None: check(assert_type(pd.to_numeric(1), float), int) check(assert_type(pd.to_numeric("1.2"), float), float) check(assert_type(pd.to_numeric("blerg", errors="coerce"), float), float) - check(assert_type(pd.to_numeric("blerg", errors="ignore"), Scalar), str) + with pytest_warns_bounded( + FutureWarning, "errors='ignore' is deprecated", lower="2.1.99" + ): + check(assert_type(pd.to_numeric("blerg", errors="ignore"), Scalar), str) check(assert_type(pd.to_numeric(1, downcast="signed"), float), int) check(assert_type(pd.to_numeric(1, downcast="unsigned"), float), int) check(assert_type(pd.to_numeric(1, downcast="float"), float), int) @@ -606,10 +609,15 @@ def test_to_numeric_array_like() -> None: ), np.ndarray, ) - check( - assert_type(pd.to_numeric([1.0, 2.0, "blerg"], errors="ignore"), npt.NDArray), - np.ndarray, - ) + with pytest_warns_bounded( + FutureWarning, "errors='ignore' is deprecated", lower="2.1.99" + ): + check( + assert_type( + pd.to_numeric([1.0, 2.0, "blerg"], errors="ignore"), npt.NDArray + ), + np.ndarray, + ) check( assert_type( pd.to_numeric((1.0, 2.0, 3.0)), @@ -638,12 +646,15 @@ def test_to_numeric_array_series() -> None: ), pd.Series, ) - check( - assert_type( - pd.to_numeric(pd.Series([1, 2, "blerg"]), errors="ignore"), pd.Series - ), - pd.Series, - ) + with pytest_warns_bounded( + FutureWarning, "errors='ignore' is deprecated", lower="2.1.99" + ): + check( + assert_type( + pd.to_numeric(pd.Series([1, 2, "blerg"]), errors="ignore"), pd.Series + ), + pd.Series, + ) check( assert_type(pd.to_numeric(pd.Series([1, 2, 3]), downcast="signed"), pd.Series), pd.Series, @@ -1958,7 +1969,7 @@ def g(x: pd.Series) -> int: }, index=idx, ) - with pytest_warns_bounded(UserWarning, "'M' will be deprecated", lower="2.1.99"): + with pytest_warns_bounded(FutureWarning, "'M' is deprecated", lower="2.1.99"): check( assert_type( pd.pivot_table( @@ -1968,6 +1979,7 @@ def g(x: pd.Series) -> int: ), pd.DataFrame, ) + with pytest_warns_bounded(FutureWarning, "'M' is deprecated,", lower="2.1.99"): check( assert_type( pd.pivot_table( diff --git a/tests/test_scalars.py b/tests/test_scalars.py index af74019bd..b308965cb 100644 --- a/tests/test_scalars.py +++ b/tests/test_scalars.py @@ -384,7 +384,8 @@ def test_interval_cmp(): def test_timedelta_construction() -> None: - check(assert_type(pd.Timedelta(1, "H"), pd.Timedelta), pd.Timedelta) + with pytest_warns_bounded(FutureWarning, "'H' is deprecated", lower="2.1.99"): + check(assert_type(pd.Timedelta(1, "H"), pd.Timedelta), pd.Timedelta) with pytest_warns_bounded(FutureWarning, "'T' is deprecated", lower="2.1.99"): check(assert_type(pd.Timedelta(1, "T"), pd.Timedelta), pd.Timedelta) with pytest_warns_bounded(FutureWarning, "'S' is deprecated", lower="2.1.99"): @@ -1536,24 +1537,34 @@ def test_timestamp_misc_methods() -> None: check(assert_type(ts2.round("1s", ambiguous=False), pd.Timestamp), pd.Timestamp) check(assert_type(ts2.round("1s", ambiguous="NaT"), pd.Timestamp), pd.Timestamp) - check( - assert_type(ts2.round("2H", nonexistent="shift_forward"), pd.Timestamp), - pd.Timestamp, - ) - check( - assert_type(ts2.round("2H", nonexistent="shift_backward"), pd.Timestamp), - pd.Timestamp, - ) - check(assert_type(ts2.round("2H", nonexistent="NaT"), pd.Timestamp), pd.Timestamp) - check(assert_type(ts2.round("2H", nonexistent="raise"), pd.Timestamp), pd.Timestamp) - check( - assert_type(ts2.round("2H", nonexistent=pd.Timedelta(24, "H")), pd.Timestamp), - pd.Timestamp, - ) - check( - assert_type(ts2.round("2H", nonexistent=dt.timedelta(hours=24)), pd.Timestamp), - pd.Timestamp, - ) + with pytest_warns_bounded(FutureWarning, "'H' is deprecated ", lower="2.1.99"): + check( + assert_type(ts2.round("2H", nonexistent="shift_forward"), pd.Timestamp), + pd.Timestamp, + ) + check( + assert_type(ts2.round("2H", nonexistent="shift_backward"), pd.Timestamp), + pd.Timestamp, + ) + check( + assert_type(ts2.round("2H", nonexistent="NaT"), pd.Timestamp), pd.Timestamp + ) + check( + assert_type(ts2.round("2H", nonexistent="raise"), pd.Timestamp), + pd.Timestamp, + ) + check( + assert_type( + ts2.round("2H", nonexistent=pd.Timedelta(24, "H")), pd.Timestamp + ), + pd.Timestamp, + ) + check( + assert_type( + ts2.round("2H", nonexistent=dt.timedelta(hours=24)), pd.Timestamp + ), + pd.Timestamp, + ) check(assert_type(ts2.ceil("1s"), pd.Timestamp), pd.Timestamp) check(assert_type(ts2.ceil("1s", ambiguous="raise"), pd.Timestamp), pd.Timestamp) @@ -1561,24 +1572,33 @@ def test_timestamp_misc_methods() -> None: check(assert_type(ts2.ceil("1s", ambiguous=False), pd.Timestamp), pd.Timestamp) check(assert_type(ts2.ceil("1s", ambiguous="NaT"), pd.Timestamp), pd.Timestamp) - check( - assert_type(ts2.ceil("2H", nonexistent="shift_forward"), pd.Timestamp), - pd.Timestamp, - ) - check( - assert_type(ts2.ceil("2H", nonexistent="shift_backward"), pd.Timestamp), - pd.Timestamp, - ) - check(assert_type(ts2.ceil("2H", nonexistent="NaT"), pd.Timestamp), pd.Timestamp) - check(assert_type(ts2.ceil("2H", nonexistent="raise"), pd.Timestamp), pd.Timestamp) - check( - assert_type(ts2.ceil("2H", nonexistent=pd.Timedelta(24, "H")), pd.Timestamp), - pd.Timestamp, - ) - check( - assert_type(ts2.ceil("2H", nonexistent=dt.timedelta(hours=24)), pd.Timestamp), - pd.Timestamp, - ) + with pytest_warns_bounded(FutureWarning, "'H' is deprecated", lower="2.1.99"): + check( + assert_type(ts2.ceil("2H", nonexistent="shift_forward"), pd.Timestamp), + pd.Timestamp, + ) + check( + assert_type(ts2.ceil("2H", nonexistent="shift_backward"), pd.Timestamp), + pd.Timestamp, + ) + check( + assert_type(ts2.ceil("2H", nonexistent="NaT"), pd.Timestamp), pd.Timestamp + ) + check( + assert_type(ts2.ceil("2H", nonexistent="raise"), pd.Timestamp), pd.Timestamp + ) + check( + assert_type( + ts2.ceil("2H", nonexistent=pd.Timedelta(24, "H")), pd.Timestamp + ), + pd.Timestamp, + ) + check( + assert_type( + ts2.ceil("2H", nonexistent=dt.timedelta(hours=24)), pd.Timestamp + ), + pd.Timestamp, + ) check(assert_type(ts2.floor("1s"), pd.Timestamp), pd.Timestamp) check(assert_type(ts2.floor("1s", ambiguous="raise"), pd.Timestamp), pd.Timestamp) @@ -1586,24 +1606,34 @@ def test_timestamp_misc_methods() -> None: check(assert_type(ts2.floor("1s", ambiguous=False), pd.Timestamp), pd.Timestamp) check(assert_type(ts2.floor("1s", ambiguous="NaT"), pd.Timestamp), pd.Timestamp) - check( - assert_type(ts2.floor("2H", nonexistent="shift_forward"), pd.Timestamp), - pd.Timestamp, - ) - check( - assert_type(ts2.floor("2H", nonexistent="shift_backward"), pd.Timestamp), - pd.Timestamp, - ) - check(assert_type(ts2.floor("2H", nonexistent="NaT"), pd.Timestamp), pd.Timestamp) - check(assert_type(ts2.floor("2H", nonexistent="raise"), pd.Timestamp), pd.Timestamp) - check( - assert_type(ts2.floor("2H", nonexistent=pd.Timedelta(24, "H")), pd.Timestamp), - pd.Timestamp, - ) - check( - assert_type(ts2.floor("2H", nonexistent=dt.timedelta(hours=24)), pd.Timestamp), - pd.Timestamp, - ) + with pytest_warns_bounded(FutureWarning, "'H' is deprecated", lower="2.1.99"): + check( + assert_type(ts2.floor("2H", nonexistent="shift_forward"), pd.Timestamp), + pd.Timestamp, + ) + check( + assert_type(ts2.floor("2H", nonexistent="shift_backward"), pd.Timestamp), + pd.Timestamp, + ) + check( + assert_type(ts2.floor("2H", nonexistent="NaT"), pd.Timestamp), pd.Timestamp + ) + check( + assert_type(ts2.floor("2H", nonexistent="raise"), pd.Timestamp), + pd.Timestamp, + ) + check( + assert_type( + ts2.floor("2H", nonexistent=pd.Timedelta(24, "H")), pd.Timestamp + ), + pd.Timestamp, + ) + check( + assert_type( + ts2.floor("2H", nonexistent=dt.timedelta(hours=24)), pd.Timestamp + ), + pd.Timestamp, + ) def test_timestamp_types_arithmetic() -> None: diff --git a/tests/test_timefuncs.py b/tests/test_timefuncs.py index 796f14cd7..3473f2897 100644 --- a/tests/test_timefuncs.py +++ b/tests/test_timefuncs.py @@ -289,10 +289,13 @@ def test_comparisons_datetimeindex() -> None: def test_to_datetime_nat() -> None: # GH 88 - check( - assert_type(pd.to_datetime("2021-03-01", errors="ignore"), pd.Timestamp), - pd.Timestamp, - ) + with pytest_warns_bounded( + FutureWarning, "errors='ignore' is deprecated", lower="2.1.99" + ): + check( + assert_type(pd.to_datetime("2021-03-01", errors="ignore"), pd.Timestamp), + pd.Timestamp, + ) check( assert_type(pd.to_datetime("2021-03-01", errors="raise"), pd.Timestamp), pd.Timestamp, @@ -746,10 +749,13 @@ def test_to_timedelta_scalar() -> None: assert_type(pd.to_timedelta(10, "ms", errors="raise"), pd.Timedelta), pd.Timedelta, ) - check( - assert_type(pd.to_timedelta("10ms", errors="ignore"), pd.Timedelta), - pd.Timedelta, - ) + with pytest_warns_bounded( + FutureWarning, "errors='ignore' is deprecated", lower="2.1.99" + ): + check( + assert_type(pd.to_timedelta("10ms", errors="ignore"), pd.Timedelta), + pd.Timedelta, + ) check( assert_type( pd.to_timedelta(dt.timedelta(milliseconds=10), errors="coerce"),