Skip to content

Commit 061c1a7

Browse files
committed
fix nightly runs
1 parent f340905 commit 061c1a7

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
@@ -6,6 +6,7 @@
66
from typing_extensions import assert_type
77

88
from tests import (
9+
PD_LTE_23,
910
check,
1011
np_ndarray_bool,
1112
)
@@ -38,9 +39,13 @@ def test_string_accessors_boolean_series():
3839
_check(
3940
assert_type(s.str.contains("a"), "pd.Series[bool]"),
4041
)
41-
_check(
42-
assert_type(s.str.contains(re.compile(r"a")), "pd.Series[bool]"),
43-
)
42+
if PD_LTE_23:
43+
# Bug in pandas 3.0 dev https://github.com/pandas-dev/pandas/issues/61942
44+
_check(
45+
assert_type(
46+
s.str.contains(re.compile(r"a"), regex=True), "pd.Series[bool]"
47+
),
48+
)
4449
_check(assert_type(s.str.endswith("e"), "pd.Series[bool]"))
4550
_check(assert_type(s.str.endswith(("e", "f")), "pd.Series[bool]"))
4651
_check(assert_type(s.str.fullmatch("apple"), "pd.Series[bool]"))
@@ -66,9 +71,13 @@ def test_string_accessors_boolean_index():
6671
_check(
6772
assert_type(idx.str.contains("a"), np_ndarray_bool),
6873
)
69-
_check(
70-
assert_type(idx.str.contains(re.compile(r"a")), np_ndarray_bool),
71-
)
74+
if PD_LTE_23:
75+
# Bug in pandas 3.0 dev https://github.com/pandas-dev/pandas/issues/61942
76+
_check(
77+
assert_type(
78+
idx.str.contains(re.compile(r"a"), regex=True), np_ndarray_bool
79+
),
80+
)
7281
_check(assert_type(idx.str.endswith("e"), np_ndarray_bool))
7382
_check(assert_type(idx.str.endswith(("e", "f")), np_ndarray_bool))
7483
_check(assert_type(idx.str.fullmatch("apple"), np_ndarray_bool))

0 commit comments

Comments
 (0)