8
8
9
9
from tests import (
10
10
PD_LTE_23 ,
11
+ TYPE_CHECKING_INVALID_USAGE ,
11
12
check ,
12
13
np_ndarray_bool ,
13
14
)
@@ -50,7 +51,9 @@ def test_string_accessors_boolean_series():
50
51
_check (assert_type (s .str .endswith ("e" ), "pd.Series[bool]" ))
51
52
_check (assert_type (s .str .endswith (("e" , "f" )), "pd.Series[bool]" ))
52
53
_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]" ))
54
57
_check (assert_type (s .str .isalnum (), "pd.Series[bool]" ))
55
58
_check (assert_type (s .str .isalpha (), "pd.Series[bool]" ))
56
59
_check (assert_type (s .str .isdecimal (), "pd.Series[bool]" ))
@@ -61,7 +64,9 @@ def test_string_accessors_boolean_series():
61
64
_check (assert_type (s .str .istitle (), "pd.Series[bool]" ))
62
65
_check (assert_type (s .str .isupper (), "pd.Series[bool]" ))
63
66
_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]" ))
65
70
66
71
67
72
def test_string_accessors_boolean_index ():
@@ -84,7 +89,9 @@ def test_string_accessors_boolean_index():
84
89
_check (assert_type (idx .str .endswith ("e" ), np_ndarray_bool ))
85
90
_check (assert_type (idx .str .endswith (("e" , "f" )), np_ndarray_bool ))
86
91
_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 ))
88
95
_check (assert_type (idx .str .isalnum (), np_ndarray_bool ))
89
96
_check (assert_type (idx .str .isalpha (), np_ndarray_bool ))
90
97
_check (assert_type (idx .str .isdecimal (), np_ndarray_bool ))
@@ -95,7 +102,9 @@ def test_string_accessors_boolean_index():
95
102
_check (assert_type (idx .str .istitle (), np_ndarray_bool ))
96
103
_check (assert_type (idx .str .isupper (), np_ndarray_bool ))
97
104
_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 ))
99
108
100
109
101
110
def test_string_accessors_integer_series ():
@@ -228,10 +237,10 @@ def test_string_accessors_list_series():
228
237
229
238
# rsplit doesn't accept compiled pattern
230
239
# 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
+ )
235
244
236
245
237
246
def test_string_accessors_list_index ():
@@ -248,10 +257,10 @@ def test_string_accessors_list_index():
248
257
249
258
# rsplit doesn't accept compiled pattern
250
259
# 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
+ )
255
264
256
265
257
266
def test_string_accessors_expanding_series ():
0 commit comments