Don't use 'is' with literals
authorDebian Science Team <debian-science-maintainers@lists.alioth.debian.org>
Thu, 7 May 2020 10:57:06 +0000 (11:57 +0100)
committerRebecca N. Palmer <rebecca_palmer@zoho.com>
Thu, 7 May 2020 10:57:06 +0000 (11:57 +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 a6fd980faefcdf8b47a10ced896df9360428ceea..cb3bb22a745546c23801a22ac02fe4699aa4f8f0 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