11try :
2- None < 0
2+ # will raise TypeError under python 3
3+ None < 0 # noqa: PLR0133, B015
34
45 def NoneAndDictComparable (v ):
56 return v
67except 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
7374def _test ():
75+ # ruff: noqa: S101, B011, PLC0415, PLR2004
7476 import sys
7577 _py3 = sys .version_info [0 ] > 2
7678
0 commit comments