Browse Source

ref: clean up py2 `__nonzero__` compat (#61364)

<!-- Describe your PR here. -->
anthony sottile 1 year ago
parent
commit
ec05e48802

+ 0 - 4
src/bitfield/types.py

@@ -20,8 +20,6 @@ class Bit:
     def __bool__(self):
         return self.is_set
 
-    __nonzero__ = __bool__
-
     def __eq__(self, value):
         if isinstance(value, Bit):
             return value.number == self.number and value.is_set == self.is_set
@@ -149,8 +147,6 @@ class BitHandler:
     def __bool__(self):
         return bool(self._value)
 
-    __nonzero__ = __bool__
-
     def __and__(self, value):
         return BitHandler(self._value & int(value), self._keys)
 

+ 0 - 3
src/sentry/utils/cursors.py

@@ -49,9 +49,6 @@ class Cursor:
     def __bool__(self) -> bool:
         return bool(self.has_results)
 
-    # python2 compatibility
-    __nonzero__ = __bool__
-
     @classmethod
     def from_string(cls, cursor_str: str) -> Cursor:
         bits = cursor_str.split(":")

+ 1 - 1
tests/sentry/db/models/fields/bitfield/test_bitfield.py

@@ -71,7 +71,7 @@ class BitHandlerTest(unittest.TestCase):
         self.assertEqual(bool(bithandler.FLAG_2), False)
         self.assertEqual(bool(bithandler.FLAG_3), False)
 
-    def test_nonzero_default(self):
+    def test_bool_default(self):
         bithandler = BitHandler(1, ("FLAG_0", "FLAG_1", "FLAG_2", "FLAG_3"))
         self.assertEqual(bool(bithandler.FLAG_0), True)
         self.assertEqual(bool(bithandler.FLAG_1), False)