Skip to content

Commit 9093962

Browse files
committed
Refactor typing
1 parent d47bf11 commit 9093962

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

pandas/_testing/_warnings.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,11 @@ class for all warnings. To raise multiple types of exceptions,
107107
yield w
108108
finally:
109109
if expected_warning:
110-
if type(expected_warning) == tuple and must_find_all_warnings:
111-
expected_warning = cast(tuple[type[Warning]], expected_warning)
110+
if isinstance(expected_warning, tuple) and must_find_all_warnings:
112111
match = (
113112
match
114-
if type(match) == tuple
115-
else tuple(
116-
cast(str | None, match)
117-
for i in range(len(expected_warning))
118-
)
113+
if isinstance(match, tuple)
114+
else tuple(match for i in range(len(expected_warning)))
119115
)
120116
for warning_type, warning_match in zip(expected_warning, match):
121117
_assert_caught_expected_warning(
@@ -126,11 +122,10 @@ class for all warnings. To raise multiple types of exceptions,
126122
)
127123
else:
128124
expected_warning = cast(type[Warning], expected_warning)
129-
match = cast(
130-
str,
125+
match = (
131126
"|".join(m for m in match if m)
132-
if type(match) == tuple
133-
else match,
127+
if isinstance(match, tuple)
128+
else match
134129
)
135130
_assert_caught_expected_warning(
136131
caught_warnings=w,

0 commit comments

Comments
 (0)