Don't use 'is' with literals
authorDebian Science Team <debian-science-maintainers@lists.alioth.debian.org>
Wed, 26 Aug 2020 21:34:50 +0000 (22:34 +0100)
committerRebecca N. Palmer <rebecca_palmer@zoho.com>
Wed, 26 Aug 2020 21:34:50 +0000 (22:34 +0100)
It causes a SyntaxWarning on install, and possibly undefined test results

Author: Rebecca N. Palmer <rebecca_palmer@zoho.com>
Bug-Debian: https://bugs.debian.org/956021
Forwarded: https://github.com/pandas-dev/pandas/pull/33322

Gbp-Pq: Name fix_is_warnings.patch

pandas/tests/frame/test_alter_axes.py

index 602ea9ca0471ab5365de3aac51175a5f8054676a..2a94cf8e816c2dd498b8859801478ecfa163538c 100644 (file)
@@ -236,9 +236,16 @@ class TestDataFrameAlterAxes:
 
         # need to adapt first drop for case that both keys are 'A' --
         # cannot drop the same column twice;
-        # use "is" because == would give ambiguous Boolean error for containers
+        # plain == would give ambiguous Boolean error for containers
         first_drop = (
-            False if (keys[0] is "A" and keys[1] is "A") else drop  # noqa: F632
+            False
+            if (
+                type(keys[0]) == str
+                and keys[0] == "A"
+                and type(keys[1]) == str
+                and keys[1] == "A"
+            )
+            else drop
         )
         # to test against already-tested behaviour, we add sequentially,
         # hence second append always True; must wrap keys in list, otherwise