88
99from tests import (
1010 PD_LTE_23 ,
11+ TYPE_CHECKING_INVALID_USAGE ,
1112 check ,
1213 np_ndarray_bool ,
1314)
@@ -50,7 +51,9 @@ def test_string_accessors_boolean_series():
5051 _check (assert_type (s .str .endswith ("e" ), "pd.Series[bool]" ))
5152 _check (assert_type (s .str .endswith (("e" , "f" )), "pd.Series[bool]" ))
5253 _check (assert_type (s .str .fullmatch ("apple" ), "pd.Series[bool]" ))
53- _check (assert_type (s .str .fullmatch (re .compile (r"apple" )), "pd.Series[bool]" ))
54+ if PD_LTE_23 :
55+ # Bug in 3.0 dev: https://github.com/pandas-dev/pandas/issues/61952
56+ _check (assert_type (s .str .fullmatch (re .compile (r"apple" )), "pd.Series[bool]" ))
5457 _check (assert_type (s .str .isalnum (), "pd.Series[bool]" ))
5558 _check (assert_type (s .str .isalpha (), "pd.Series[bool]" ))
5659 _check (assert_type (s .str .isdecimal (), "pd.Series[bool]" ))
@@ -61,7 +64,9 @@ def test_string_accessors_boolean_series():
6164 _check (assert_type (s .str .istitle (), "pd.Series[bool]" ))
6265 _check (assert_type (s .str .isupper (), "pd.Series[bool]" ))
6366 _check (assert_type (s .str .match ("pp" ), "pd.Series[bool]" ))
64- _check (assert_type (s .str .match (re .compile (r"pp" )), "pd.Series[bool]" ))
67+ if PD_LTE_23 :
68+ # Bug in 3.0 dev: https://github.com/pandas-dev/pandas/issues/61952
69+ _check (assert_type (s .str .match (re .compile (r"pp" )), "pd.Series[bool]" ))
6570
6671
6772def test_string_accessors_boolean_index ():
@@ -84,7 +89,9 @@ def test_string_accessors_boolean_index():
8489 _check (assert_type (idx .str .endswith ("e" ), np_ndarray_bool ))
8590 _check (assert_type (idx .str .endswith (("e" , "f" )), np_ndarray_bool ))
8691 _check (assert_type (idx .str .fullmatch ("apple" ), np_ndarray_bool ))
87- _check (assert_type (idx .str .fullmatch (re .compile (r"apple" )), np_ndarray_bool ))
92+ if PD_LTE_23 :
93+ # Bug in 3.0 dev: https://github.com/pandas-dev/pandas/issues/61952
94+ _check (assert_type (idx .str .fullmatch (re .compile (r"apple" )), np_ndarray_bool ))
8895 _check (assert_type (idx .str .isalnum (), np_ndarray_bool ))
8996 _check (assert_type (idx .str .isalpha (), np_ndarray_bool ))
9097 _check (assert_type (idx .str .isdecimal (), np_ndarray_bool ))
@@ -95,7 +102,9 @@ def test_string_accessors_boolean_index():
95102 _check (assert_type (idx .str .istitle (), np_ndarray_bool ))
96103 _check (assert_type (idx .str .isupper (), np_ndarray_bool ))
97104 _check (assert_type (idx .str .match ("pp" ), np_ndarray_bool ))
98- _check (assert_type (idx .str .match (re .compile (r"pp" )), np_ndarray_bool ))
105+ if PD_LTE_23 :
106+ # Bug in 3.0 dev: https://github.com/pandas-dev/pandas/issues/61952
107+ _check (assert_type (idx .str .match (re .compile (r"pp" )), np_ndarray_bool ))
99108
100109
101110def test_string_accessors_integer_series ():
@@ -228,10 +237,10 @@ def test_string_accessors_list_series():
228237
229238 # rsplit doesn't accept compiled pattern
230239 # it doesn't raise at runtime but produces a nan
231- bad_rsplit_result = s . str . rsplit (
232- re . compile ( r"a" ) # type: ignore[call-overload] # pyright: ignore[reportArgumentType]
233- )
234- assert bad_rsplit_result . isna (). all ( )
240+ if TYPE_CHECKING_INVALID_USAGE :
241+ bad_rsplit_result = s . str . rsplit (
242+ re . compile ( r"a" ) # type: ignore[call-overload] # pyright: ignore[reportArgumentType]
243+ )
235244
236245
237246def test_string_accessors_list_index ():
@@ -248,10 +257,10 @@ def test_string_accessors_list_index():
248257
249258 # rsplit doesn't accept compiled pattern
250259 # it doesn't raise at runtime but produces a nan
251- bad_rsplit_result = idx . str . rsplit (
252- re . compile ( r"a" ) # type: ignore[call-overload] # pyright: ignore[reportArgumentType]
253- )
254- assert bad_rsplit_result . isna (). all ( )
260+ if TYPE_CHECKING_INVALID_USAGE :
261+ bad_rsplit_result = idx . str . rsplit (
262+ re . compile ( r"a" ) # type: ignore[call-overload] # pyright: ignore[reportArgumentType]
263+ )
255264
256265
257266def test_string_accessors_expanding_series ():
0 commit comments