Skip to content

Commit 4c3fd79

Browse files
authored
fix nightly runs (pandas-dev#1289)
1 parent f141c69 commit 4c3fd79

File tree

4 files changed

+45
-16
lines changed

4 files changed

+45
-16
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ numpy = ">= 1.23.5"
3636

3737
[tool.poetry.group.dev.dependencies]
3838
mypy = "1.17.0"
39-
pandas = "2.3.0"
39+
pandas = "2.3.1"
4040
pyarrow = ">=10.0.1"
4141
pytest = ">=7.1.2"
4242
pyright = ">=1.1.400"

tests/test_frame.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2949,7 +2949,10 @@ def test_dataframe_replace() -> None:
29492949
check(assert_type(df.replace(regex=pattern, value="x"), pd.DataFrame), pd.DataFrame)
29502950

29512951
check(assert_type(df.replace(["a"], ["x"]), pd.DataFrame), pd.DataFrame)
2952-
check(assert_type(df.replace([pattern], ["x"]), pd.DataFrame), pd.DataFrame)
2952+
check(
2953+
assert_type(df.replace([pattern], ["x"], regex=True), pd.DataFrame),
2954+
pd.DataFrame,
2955+
)
29532956
check(assert_type(df.replace(regex=["a"], value=["x"]), pd.DataFrame), pd.DataFrame)
29542957
check(
29552958
assert_type(df.replace(regex=[pattern], value=["x"]), pd.DataFrame),
@@ -2958,7 +2961,9 @@ def test_dataframe_replace() -> None:
29582961

29592962
check(assert_type(df.replace({"a": "x"}), pd.DataFrame), pd.DataFrame)
29602963
check(assert_type(df.replace(replace_dict_scalar), pd.DataFrame), pd.DataFrame)
2961-
check(assert_type(df.replace({pattern: "x"}), pd.DataFrame), pd.DataFrame)
2964+
check(
2965+
assert_type(df.replace({pattern: "x"}, regex=True), pd.DataFrame), pd.DataFrame
2966+
)
29622967
check(assert_type(df.replace(pd.Series({"a": "x"})), pd.DataFrame), pd.DataFrame)
29632968
check(assert_type(df.replace(regex={"a": "x"}), pd.DataFrame), pd.DataFrame)
29642969
check(assert_type(df.replace(regex={pattern: "x"}), pd.DataFrame), pd.DataFrame)
@@ -3003,7 +3008,9 @@ def test_dataframe_replace() -> None:
30033008
pd.DataFrame,
30043009
)
30053010
check(
3006-
assert_type(df.replace({"col1": [pattern]}, {"col1": ["x"]}), pd.DataFrame),
3011+
assert_type(
3012+
df.replace({"col1": [pattern]}, {"col1": ["x"]}, regex=True), pd.DataFrame
3013+
),
30073014
pd.DataFrame,
30083015
)
30093016
check(
@@ -3037,7 +3044,10 @@ def test_dataframe_replace() -> None:
30373044

30383045
check(assert_type(df.replace({"col1": {"a": "x"}}), pd.DataFrame), pd.DataFrame)
30393046
check(assert_type(df.replace(replace_dict_per_column), pd.DataFrame), pd.DataFrame)
3040-
check(assert_type(df.replace({"col1": {pattern: "x"}}), pd.DataFrame), pd.DataFrame)
3047+
check(
3048+
assert_type(df.replace({"col1": {pattern: "x"}}, regex=True), pd.DataFrame),
3049+
pd.DataFrame,
3050+
)
30413051
check(
30423052
assert_type(df.replace({"col1": pd.Series({"a": "x"})}), pd.DataFrame),
30433053
pd.DataFrame,
@@ -3168,7 +3178,7 @@ def test_frame_reindex_like() -> None:
31683178
with pytest_warns_bounded(
31693179
FutureWarning,
31703180
"the 'method' keyword is deprecated and will be removed in a future version. Please take steps to stop the use of 'method'",
3171-
lower="2.3.0",
3181+
lower="2.3.99",
31723182
):
31733183
check(
31743184
assert_type(

tests/test_series.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,9 +1428,14 @@ def test_types_values() -> None:
14281428
assert_type(pd.Series([1, 2, 3]).values, Union[ExtensionArray, np.ndarray]),
14291429
np.ndarray,
14301430
)
1431+
valresult_type: type[np.ndarray | ExtensionArray]
1432+
if PD_LTE_23:
1433+
valresult_type = np.ndarray
1434+
else:
1435+
valresult_type = ExtensionArray
14311436
check(
14321437
assert_type(pd.Series(list("aabc")).values, Union[np.ndarray, ExtensionArray]),
1433-
np.ndarray,
1438+
valresult_type,
14341439
)
14351440
check(
14361441
assert_type(
@@ -1707,11 +1712,14 @@ def test_series_replace() -> None:
17071712
pd.Series,
17081713
)
17091714
check(
1710-
assert_type(s.replace({pattern: "z"}), "pd.Series[str]"),
1715+
assert_type(s.replace({pattern: "z"}, regex=True), "pd.Series[str]"),
17111716
pd.Series,
17121717
)
17131718
check(assert_type(s.replace(["a"], ["x"]), "pd.Series[str]"), pd.Series)
1714-
check(assert_type(s.replace([pattern], ["x"]), "pd.Series[str]"), pd.Series)
1719+
check(
1720+
assert_type(s.replace([pattern], ["x"], regex=True), "pd.Series[str]"),
1721+
pd.Series,
1722+
)
17151723
check(assert_type(s.replace(r"^a.*", "x", regex=True), "pd.Series[str]"), pd.Series)
17161724
check(assert_type(s.replace(value="x", regex=r"^a.*"), "pd.Series[str]"), pd.Series)
17171725
check(
@@ -3793,7 +3801,9 @@ def test_path_div() -> None:
37933801
# GH 682
37943802
folder = Path.cwd()
37953803
files = pd.Series(["a.png", "b.png"])
3796-
check(assert_type(folder / files, pd.Series), pd.Series, Path)
3804+
if PD_LTE_23:
3805+
# Bug in 3.0 https://github.com/pandas-dev/pandas/issues/61940
3806+
check(assert_type(folder / files, pd.Series), pd.Series, Path)
37973807

37983808
folders = pd.Series([folder, folder])
37993809
check(assert_type(folders / Path("a.png"), pd.Series), pd.Series, Path)

tests/test_string_accessors.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from typing_extensions import assert_type
88

99
from tests import (
10+
PD_LTE_23,
1011
check,
1112
np_ndarray_bool,
1213
)
@@ -39,9 +40,13 @@ def test_string_accessors_boolean_series():
3940
_check(
4041
assert_type(s.str.contains("a"), "pd.Series[bool]"),
4142
)
42-
_check(
43-
assert_type(s.str.contains(re.compile(r"a")), "pd.Series[bool]"),
44-
)
43+
if PD_LTE_23:
44+
# Bug in pandas 3.0 dev https://github.com/pandas-dev/pandas/issues/61942
45+
_check(
46+
assert_type(
47+
s.str.contains(re.compile(r"a"), regex=True), "pd.Series[bool]"
48+
),
49+
)
4550
_check(assert_type(s.str.endswith("e"), "pd.Series[bool]"))
4651
_check(assert_type(s.str.endswith(("e", "f")), "pd.Series[bool]"))
4752
_check(assert_type(s.str.fullmatch("apple"), "pd.Series[bool]"))
@@ -69,9 +74,13 @@ def test_string_accessors_boolean_index():
6974
_check(
7075
assert_type(idx.str.contains("a"), np_ndarray_bool),
7176
)
72-
_check(
73-
assert_type(idx.str.contains(re.compile(r"a")), np_ndarray_bool),
74-
)
77+
if PD_LTE_23:
78+
# Bug in pandas 3.0 dev https://github.com/pandas-dev/pandas/issues/61942
79+
_check(
80+
assert_type(
81+
idx.str.contains(re.compile(r"a"), regex=True), np_ndarray_bool
82+
),
83+
)
7584
_check(assert_type(idx.str.endswith("e"), np_ndarray_bool))
7685
_check(assert_type(idx.str.endswith(("e", "f")), np_ndarray_bool))
7786
_check(assert_type(idx.str.fullmatch("apple"), np_ndarray_bool))

0 commit comments

Comments
 (0)