Skip to content

Commit cbd4134

Browse files
authored
CI: ignore warnings from pandas-nightly (#669)
* CI: ignore warnings from pandas-nightly * 3.8
1 parent 55fca56 commit cbd4134

File tree

7 files changed

+151
-309
lines changed

7 files changed

+151
-309
lines changed

scripts/test/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,14 @@ def stubtest(allowlist: str, check_missing: bool, nightly: bool) -> None:
4949

5050

5151
def pytest(nightly: bool) -> None:
52-
steps = [_step.nightly] if nightly else []
53-
run_job(steps + [_step.pytest])
52+
setup_steps = []
53+
pytest_step = _step.pytest
54+
if nightly:
55+
pytest_step = dataclasses.replace(
56+
_step.pytest, run=partial(_step.pytest.run, flags=())
57+
)
58+
setup_steps = [_step.nightly]
59+
run_job(setup_steps + [pytest_step])
5460

5561

5662
def mypy_src(mypy_nightly: bool) -> None:

scripts/test/run.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from pathlib import Path
24
import subprocess
35
import sys
@@ -13,8 +15,8 @@ def pyright_src():
1315
subprocess.run(cmd, check=True)
1416

1517

16-
def pytest():
17-
cmd = ["pytest", "--cache-clear", "-Werror"]
18+
def pytest(flags: tuple[str, ...] = ("-Werror",)):
19+
cmd = ["pytest", "--cache-clear", *flags]
1820
subprocess.run(cmd, check=True)
1921

2022

tests/test_api_types.py

Lines changed: 35 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88

99
from pandas._typing import DtypeObj
1010

11-
from tests import (
12-
check,
13-
pytest_warns_bounded,
14-
)
11+
from tests import check
1512

1613
nparr = np.array([1, 2, 3])
1714
arr = pd.Series([1, 2, 3])
@@ -55,20 +52,12 @@ def test_is_bool_dtype() -> None:
5552

5653

5754
def test_is_categorical_dtype() -> None:
58-
with pytest_warns_bounded(
59-
FutureWarning,
60-
match="is_categorical_dtype is deprecated and will be removed in a future version",
61-
lower="2.0.99",
62-
):
63-
check(assert_type(api.is_categorical_dtype(arr), bool), bool)
64-
check(assert_type(api.is_categorical_dtype(nparr), bool), bool)
65-
check(assert_type(api.is_categorical_dtype(dtylike), bool), bool)
66-
check(
67-
assert_type(api.is_categorical_dtype(dframe), bool),
68-
bool,
69-
)
70-
check(assert_type(api.is_categorical_dtype(ind), bool), bool)
71-
check(assert_type(api.is_categorical_dtype(ExtensionDtype), bool), bool)
55+
check(assert_type(api.is_categorical_dtype(arr), bool), bool)
56+
check(assert_type(api.is_categorical_dtype(nparr), bool), bool)
57+
check(assert_type(api.is_categorical_dtype(dtylike), bool), bool)
58+
check(assert_type(api.is_categorical_dtype(dframe), bool), bool)
59+
check(assert_type(api.is_categorical_dtype(ind), bool), bool)
60+
check(assert_type(api.is_categorical_dtype(ExtensionDtype), bool), bool)
7261

7362

7463
def test_is_complex() -> None:
@@ -132,20 +121,12 @@ def test_is_datetime64_ns_dtype() -> None:
132121

133122

134123
def test_is_datetime64tz_dtype() -> None:
135-
with pytest_warns_bounded(
136-
FutureWarning,
137-
match="is_datetime64tz_dtype is deprecated and will be removed in a future version",
138-
lower="2.0.99",
139-
):
140-
check(assert_type(api.is_datetime64tz_dtype(arr), bool), bool)
141-
check(assert_type(api.is_datetime64tz_dtype(nparr), bool), bool)
142-
check(assert_type(api.is_datetime64tz_dtype(dtylike), bool), bool)
143-
check(
144-
assert_type(api.is_datetime64tz_dtype(dframe), bool),
145-
bool,
146-
)
147-
check(assert_type(api.is_datetime64tz_dtype(ind), bool), bool)
148-
check(assert_type(api.is_datetime64tz_dtype(ExtensionDtype), bool), bool)
124+
check(assert_type(api.is_datetime64tz_dtype(arr), bool), bool)
125+
check(assert_type(api.is_datetime64tz_dtype(nparr), bool), bool)
126+
check(assert_type(api.is_datetime64tz_dtype(dtylike), bool), bool)
127+
check(assert_type(api.is_datetime64tz_dtype(dframe), bool), bool)
128+
check(assert_type(api.is_datetime64tz_dtype(ind), bool), bool)
129+
check(assert_type(api.is_datetime64tz_dtype(ExtensionDtype), bool), bool)
149130

150131

151132
def test_is_dict_like() -> None:
@@ -222,20 +203,12 @@ def test_is_hashable() -> None:
222203

223204

224205
def test_is_int64_dtype() -> None:
225-
with pytest_warns_bounded(
226-
FutureWarning,
227-
match="is_int64_dtype is deprecated and will be removed in a future version",
228-
lower="2.0.99",
229-
):
230-
check(assert_type(api.is_int64_dtype(arr), bool), bool)
231-
check(assert_type(api.is_int64_dtype(nparr), bool), bool)
232-
check(assert_type(api.is_int64_dtype(dtylike), bool), bool)
233-
check(
234-
assert_type(api.is_int64_dtype(dframe), bool),
235-
bool,
236-
)
237-
check(assert_type(api.is_int64_dtype(ind), bool), bool)
238-
# check(assert_type(api.is_int64_dtype(ExtensionDtype), bool), bool) pandas GH 50923
206+
check(assert_type(api.is_int64_dtype(arr), bool), bool)
207+
check(assert_type(api.is_int64_dtype(nparr), bool), bool)
208+
check(assert_type(api.is_int64_dtype(dtylike), bool), bool)
209+
check(assert_type(api.is_int64_dtype(dframe), bool), bool)
210+
check(assert_type(api.is_int64_dtype(ind), bool), bool)
211+
# check(assert_type(api.is_int64_dtype(ExtensionDtype), bool), bool) pandas GH 50923
239212

240213

241214
def test_is_integer() -> None:
@@ -275,21 +248,13 @@ def test_is_interval() -> None:
275248

276249

277250
def test_is_interval_dtype() -> None:
278-
with pytest_warns_bounded(
279-
FutureWarning,
280-
match="is_interval_dtype is deprecated and will be removed in a future version",
281-
lower="2.0.99",
282-
):
283-
check(assert_type(api.is_interval_dtype(obj), bool), bool)
284-
check(assert_type(api.is_interval_dtype(nparr), bool), bool)
285-
check(assert_type(api.is_interval_dtype(dtylike), bool), bool)
286-
check(assert_type(api.is_interval_dtype(arr), bool), bool)
287-
check(
288-
assert_type(api.is_interval_dtype(dframe), bool),
289-
bool,
290-
)
291-
check(assert_type(api.is_interval_dtype(ind), bool), bool)
292-
check(assert_type(api.is_interval_dtype(ExtensionDtype), bool), bool)
251+
check(assert_type(api.is_interval_dtype(obj), bool), bool)
252+
check(assert_type(api.is_interval_dtype(nparr), bool), bool)
253+
check(assert_type(api.is_interval_dtype(dtylike), bool), bool)
254+
check(assert_type(api.is_interval_dtype(arr), bool), bool)
255+
check(assert_type(api.is_interval_dtype(dframe), bool), bool)
256+
check(assert_type(api.is_interval_dtype(ind), bool), bool)
257+
check(assert_type(api.is_interval_dtype(ExtensionDtype), bool), bool)
293258

294259

295260
def test_is_iterator() -> None:
@@ -362,20 +327,12 @@ def test_is_object_dtype() -> None:
362327

363328

364329
def test_is_period_dtype() -> None:
365-
with pytest_warns_bounded(
366-
FutureWarning,
367-
match="is_period_dtype is deprecated and will be removed in a future version",
368-
lower="2.0.99",
369-
):
370-
check(assert_type(api.is_period_dtype(arr), bool), bool)
371-
check(assert_type(api.is_period_dtype(nparr), bool), bool)
372-
check(assert_type(api.is_period_dtype(dtylike), bool), bool)
373-
check(
374-
assert_type(api.is_period_dtype(dframe), bool),
375-
bool,
376-
)
377-
check(assert_type(api.is_period_dtype(ind), bool), bool)
378-
check(assert_type(api.is_period_dtype(ExtensionDtype), bool), bool)
330+
check(assert_type(api.is_period_dtype(arr), bool), bool)
331+
check(assert_type(api.is_period_dtype(nparr), bool), bool)
332+
check(assert_type(api.is_period_dtype(dtylike), bool), bool)
333+
check(assert_type(api.is_period_dtype(dframe), bool), bool)
334+
check(assert_type(api.is_period_dtype(ind), bool), bool)
335+
check(assert_type(api.is_period_dtype(ExtensionDtype), bool), bool)
379336

380337

381338
def test_is_re() -> None:
@@ -421,14 +378,9 @@ def test_is_signed_integer_dtype() -> None:
421378

422379

423380
def test_is_sparse() -> None:
424-
with pytest_warns_bounded(
425-
FutureWarning,
426-
match="is_sparse is deprecated and will be removed in a future version",
427-
lower="2.0.99",
428-
):
429-
check(assert_type(api.is_sparse(arr), bool), bool)
430-
check(assert_type(api.is_sparse(nparr), bool), bool)
431-
check(assert_type(api.is_sparse(dframe), bool), bool)
381+
check(assert_type(api.is_sparse(arr), bool), bool)
382+
check(assert_type(api.is_sparse(nparr), bool), bool)
383+
check(assert_type(api.is_sparse(dframe), bool), bool)
432384

433385

434386
def test_is_string_dtype() -> None:

tests/test_frame.py

Lines changed: 46 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
PD_LTE_20,
4444
TYPE_CHECKING_INVALID_USAGE,
4545
check,
46-
pytest_warns_bounded,
4746
)
4847

4948
from pandas.io.formats.style import Styler
@@ -727,17 +726,12 @@ def gethead(s: pd.Series, y: int) -> pd.Series:
727726

728727
def test_types_applymap() -> None:
729728
df = pd.DataFrame(data={"col1": [2, 1], "col2": [3, 4]})
730-
with pytest_warns_bounded(
731-
FutureWarning,
732-
match="DataFrame.applymap has been deprecated. Use DataFrame.map instead.",
733-
lower="2.0.99",
734-
):
735-
df.applymap(lambda x: x**2)
736-
df.applymap(np.exp)
737-
df.applymap(str)
738-
# na_action parameter was added in 1.2.0 https://pandas.pydata.org/docs/whatsnew/v1.2.0.html
739-
df.applymap(np.exp, na_action="ignore")
740-
df.applymap(str, na_action=None)
729+
df.applymap(lambda x: x**2)
730+
df.applymap(np.exp)
731+
df.applymap(str)
732+
# na_action parameter was added in 1.2.0 https://pandas.pydata.org/docs/whatsnew/v1.2.0.html
733+
df.applymap(np.exp, na_action="ignore")
734+
df.applymap(str, na_action=None)
741735

742736

743737
def test_types_element_wise_arithmetic() -> None:
@@ -881,12 +875,7 @@ def test_types_groupby() -> None:
881875
df4: pd.DataFrame = df.groupby(by=["col1", "col2"]).count()
882876
df5: pd.DataFrame = df.groupby(by=["col1", "col2"]).filter(lambda x: x["col1"] > 0)
883877
df6: pd.DataFrame = df.groupby(by=["col1", "col2"]).nunique()
884-
with pytest_warns_bounded(
885-
FutureWarning,
886-
match="DataFrameGroupBy.apply operated on the grouping columns. This behavior is deprecated",
887-
lower="2.0.99",
888-
):
889-
df7: pd.DataFrame = df.groupby(by="col1").apply(sum)
878+
df7: pd.DataFrame = df.groupby(by="col1").apply(sum)
890879
df8: pd.DataFrame = df.groupby("col1").transform("sum")
891880
s1: pd.Series = df.set_index("col1")["col2"]
892881
s2: pd.Series = s1.groupby("col1").transform("sum")
@@ -1098,22 +1087,17 @@ def test_to_markdown() -> None:
10981087
def test_types_to_feather() -> None:
10991088
pytest.importorskip("pyarrow")
11001089
df = pd.DataFrame(data={"col1": [1, 1, 2], "col2": [3, 4, 5]})
1101-
with pytest_warns_bounded(
1102-
FutureWarning,
1103-
match="is_sparse is deprecated and will be removed in a future version",
1104-
lower="2.0.99",
1105-
):
1106-
with ensure_clean() as path:
1107-
df.to_feather(path)
1108-
# kwargs for pyarrow.feather.write_feather added in 1.1.0 https://pandas.pydata.org/docs/whatsnew/v1.1.0.html
1109-
df.to_feather(path, compression="zstd", compression_level=3, chunksize=2)
1110-
1111-
# to_feather has been able to accept a buffer since pandas 1.0.0
1112-
# See https://pandas.pydata.org/docs/whatsnew/v1.0.0.html
1113-
# Docstring and type were updated in 1.2.0.
1114-
# https://github.com/pandas-dev/pandas/pull/35408
1115-
with open(path, mode="wb") as file:
1116-
df.to_feather(file)
1090+
with ensure_clean() as path:
1091+
df.to_feather(path)
1092+
# kwargs for pyarrow.feather.write_feather added in 1.1.0 https://pandas.pydata.org/docs/whatsnew/v1.1.0.html
1093+
df.to_feather(path, compression="zstd", compression_level=3, chunksize=2)
1094+
1095+
# to_feather has been able to accept a buffer since pandas 1.0.0
1096+
# See https://pandas.pydata.org/docs/whatsnew/v1.0.0.html
1097+
# Docstring and type were updated in 1.2.0.
1098+
# https://github.com/pandas-dev/pandas/pull/35408
1099+
with open(path, mode="wb") as file:
1100+
df.to_feather(file)
11171101

11181102

11191103
# compare() method added in 1.1.0 https://pandas.pydata.org/docs/whatsnew/v1.1.0.html
@@ -1344,12 +1328,7 @@ def test_types_to_parquet() -> None:
13441328
allows_duplicate_labels=False
13451329
)
13461330
with ensure_clean() as path:
1347-
with pytest_warns_bounded(
1348-
FutureWarning,
1349-
match="is_sparse is deprecated and will be removed in a future version",
1350-
lower="2.0.99",
1351-
):
1352-
df.to_parquet(Path(path))
1331+
df.to_parquet(Path(path))
13531332
# to_parquet() returns bytes when no path given since 1.2.0 https://pandas.pydata.org/docs/whatsnew/v1.2.0.html
13541333
b: bytes = df.to_parquet()
13551334

@@ -1475,19 +1454,14 @@ def test_types_regressions() -> None:
14751454

14761455
# https://github.com/microsoft/python-type-stubs/issues/115
14771456
df = pd.DataFrame({"A": [1, 2, 3], "B": [5, 6, 7]})
1478-
with pytest_warns_bounded(
1479-
FutureWarning,
1480-
match="The 'closed' keyword in DatetimeIndex construction is deprecated",
1481-
lower="2.0.99",
1482-
):
1483-
pd.DatetimeIndex(
1484-
data=df["A"],
1485-
tz=None,
1486-
normalize=False,
1487-
closed=None,
1488-
ambiguous="NaT",
1489-
copy=True,
1490-
)
1457+
pd.DatetimeIndex(
1458+
data=df["A"],
1459+
tz=None,
1460+
normalize=False,
1461+
closed=None,
1462+
ambiguous="NaT",
1463+
copy=True,
1464+
)
14911465

14921466

14931467
def test_read_csv() -> None:
@@ -2053,41 +2027,32 @@ def test_groupby_apply() -> None:
20532027
def sum_mean(x: pd.DataFrame) -> float:
20542028
return x.sum().mean()
20552029

2056-
with pytest_warns_bounded(
2057-
FutureWarning,
2058-
match="DataFrameGroupBy.apply operated on the grouping columns. This behavior is deprecated",
2059-
lower="2.0.99",
2060-
):
2061-
check(assert_type(df.groupby("col1").apply(sum_mean), pd.Series), pd.Series)
2030+
check(assert_type(df.groupby("col1").apply(sum_mean), pd.Series), pd.Series)
20622031

2063-
lfunc: Callable[[pd.DataFrame], float] = lambda x: x.sum().mean()
2064-
check(
2065-
assert_type(df.groupby("col1").apply(lfunc), pd.Series),
2066-
pd.Series,
2067-
)
2032+
lfunc: Callable[[pd.DataFrame], float] = lambda x: x.sum().mean()
2033+
check(assert_type(df.groupby("col1").apply(lfunc), pd.Series), pd.Series)
20682034

2069-
def sum_to_list(x: pd.DataFrame) -> list:
2070-
return x.sum().tolist()
2035+
def sum_to_list(x: pd.DataFrame) -> list:
2036+
return x.sum().tolist()
20712037

2072-
check(assert_type(df.groupby("col1").apply(sum_to_list), pd.Series), pd.Series)
2038+
check(assert_type(df.groupby("col1").apply(sum_to_list), pd.Series), pd.Series)
20732039

2074-
def sum_to_series(x: pd.DataFrame) -> pd.Series:
2075-
return x.sum()
2040+
def sum_to_series(x: pd.DataFrame) -> pd.Series:
2041+
return x.sum()
20762042

2077-
check(
2078-
assert_type(df.groupby("col1").apply(sum_to_series), pd.DataFrame),
2079-
pd.DataFrame,
2080-
)
2043+
check(
2044+
assert_type(df.groupby("col1").apply(sum_to_series), pd.DataFrame), pd.DataFrame
2045+
)
20812046

2082-
def sample_to_df(x: pd.DataFrame) -> pd.DataFrame:
2083-
return x.sample()
2047+
def sample_to_df(x: pd.DataFrame) -> pd.DataFrame:
2048+
return x.sample()
20842049

2085-
check(
2086-
assert_type(
2087-
df.groupby("col1", group_keys=False).apply(sample_to_df), pd.DataFrame
2088-
),
2089-
pd.DataFrame,
2090-
)
2050+
check(
2051+
assert_type(
2052+
df.groupby("col1", group_keys=False).apply(sample_to_df), pd.DataFrame
2053+
),
2054+
pd.DataFrame,
2055+
)
20912056

20922057

20932058
def test_resample() -> None:

0 commit comments

Comments
 (0)