1
1
try :
2
- None < 0
2
+ # will raise TypeError under python 3
3
+ None < 0 # noqa: PLR0133, B015
3
4
4
5
def NoneAndDictComparable (v ):
5
6
return v
6
7
except TypeError :
7
8
# comparator to allow comparisons against None and dict
8
9
# comparisons (these were allowed in Python 2, but aren't allowed
9
10
# in Python 3 any more)
10
- class NoneAndDictComparable (object ):
11
+ class NoneAndDictComparable (object ): # noqa: PLW1641
11
12
def __init__ (self , value ):
12
13
self .value = value
13
14
14
- def __cmp__ (self , other ):
15
+ def __cmp__ (self , other ): # noqa: PLW3201, PLR0911
15
16
if not isinstance (other , self .__class__ ):
16
17
raise TypeError ('not comparable' )
17
18
@@ -24,7 +25,7 @@ def __cmp__(self, other):
24
25
elif other .value is None :
25
26
return 1
26
27
27
- elif type (self .value ) == tuple and type (other .value ) == tuple :
28
+ elif type (self .value ) is tuple and type (other .value ) is tuple :
28
29
for lhs , rhs in zip (self .value , other .value ):
29
30
lhsCmp = NoneAndDictComparable (lhs )
30
31
rhsCmp = NoneAndDictComparable (rhs )
@@ -34,7 +35,7 @@ def __cmp__(self, other):
34
35
35
36
return len (self .value ) - len (other .value )
36
37
37
- elif type (self .value ) == dict and type (other .value ) == dict :
38
+ elif type (self .value ) is dict and type (other .value ) is dict :
38
39
diff = len (self .value ) - len (other .value )
39
40
if diff == 0 :
40
41
lhsItems = tuple (sorted (self .value .items (),
@@ -71,6 +72,7 @@ def __gt__(self, other):
71
72
72
73
73
74
def _test ():
75
+ # ruff: noqa: S101, B011, PLC0415, PLR2004
74
76
import sys
75
77
_py3 = sys .version_info [0 ] > 2
76
78
0 commit comments