Skip to content

Commit b66b766

Browse files
Debian Science Teamrebecca-palmer
Debian Science Team
authored andcommitted
Don't use 'is' with literals
It causes a SyntaxWarning on install, and possibly undefined test results Author: Rebecca N. Palmer <[email protected]> Bug-Debian: https://bugs.debian.org/956021 Forwarded: pandas-dev/pandas#33322 Gbp-Pq: Name fix_is_warnings.patch
1 parent 17a3a65 commit b66b766

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

pandas/tests/frame/test_alter_axes.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,16 @@ def test_set_index_pass_arrays_duplicate(
236236

237237
# need to adapt first drop for case that both keys are 'A' --
238238
# cannot drop the same column twice;
239-
# use "is" because == would give ambiguous Boolean error for containers
239+
# plain == would give ambiguous Boolean error for containers
240240
first_drop = (
241-
False if (keys[0] is "A" and keys[1] is "A") else drop # noqa: F632
241+
False
242+
if (
243+
type(keys[0]) == str
244+
and keys[0] == "A"
245+
and type(keys[1]) == str
246+
and keys[1] == "A"
247+
)
248+
else drop
242249
)
243250
# to test against already-tested behaviour, we add sequentially,
244251
# hence second append always True; must wrap keys in list, otherwise

0 commit comments

Comments
 (0)