Skip to content

Commit 97b17f7

Browse files
committed
chore: more ruff lint stuff
Also use 'is' rather than '==' for type comparisons as types are objects and 'is' is used for object equality.
1 parent fce2193 commit 97b17f7

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

roundup/anypy/cmp_.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
try:
2-
None < 0
2+
# will raise TypeError under python 3
3+
None < 0 # noqa: PLR0133, B015
34

45
def NoneAndDictComparable(v):
56
return v
67
except TypeError:
78
# comparator to allow comparisons against None and dict
89
# comparisons (these were allowed in Python 2, but aren't allowed
910
# in Python 3 any more)
10-
class NoneAndDictComparable(object):
11+
class NoneAndDictComparable(object): # noqa: PLW1641
1112
def __init__(self, value):
1213
self.value = value
1314

14-
def __cmp__(self, other):
15+
def __cmp__(self, other): # noqa: PLW3201, PLR0911
1516
if not isinstance(other, self.__class__):
1617
raise TypeError('not comparable')
1718

@@ -24,7 +25,7 @@ def __cmp__(self, other):
2425
elif other.value is None:
2526
return 1
2627

27-
elif type(self.value) == tuple and type(other.value) == tuple:
28+
elif type(self.value) is tuple and type(other.value) is tuple:
2829
for lhs, rhs in zip(self.value, other.value):
2930
lhsCmp = NoneAndDictComparable(lhs)
3031
rhsCmp = NoneAndDictComparable(rhs)
@@ -34,7 +35,7 @@ def __cmp__(self, other):
3435

3536
return len(self.value) - len(other.value)
3637

37-
elif type(self.value) == dict and type(other.value) == dict:
38+
elif type(self.value) is dict and type(other.value) is dict:
3839
diff = len(self.value) - len(other.value)
3940
if diff == 0:
4041
lhsItems = tuple(sorted(self.value.items(),
@@ -71,6 +72,7 @@ def __gt__(self, other):
7172

7273

7374
def _test():
75+
# ruff: noqa: S101, B011, PLC0415, PLR2004
7476
import sys
7577
_py3 = sys.version_info[0] > 2
7678

0 commit comments

Comments
 (0)