File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1433,7 +1433,7 @@ def _check_subscript_version_check(self, node: ast.Compare) -> None:
14331433 slc = version_info .slice
14341434 if isinstance (slc , ast .Constant ):
14351435 # anything other than the integer 0 doesn't make much sense
1436- if isinstance (slc .value , int ) and slc .value == 0 :
1436+ if type (slc .value ) is int and slc .value == 0 :
14371437 must_be_single = True
14381438 else :
14391439 self .error (node , Y003 )
@@ -1445,7 +1445,7 @@ def _check_subscript_version_check(self, node: ast.Compare) -> None:
14451445 elif (
14461446 # allow only [:1] and [:2]
14471447 isinstance (slc .upper , ast .Constant )
1448- and isinstance (slc .upper .value , int )
1448+ and type (slc .upper .value ) is int
14491449 and slc .upper .value in {1 , 2 }
14501450 ):
14511451 can_have_strict_equals = slc .upper .value
@@ -1471,8 +1471,9 @@ def _check_version_check(
14711471 ) -> None :
14721472 comparator = node .comparators [0 ]
14731473 if must_be_single :
1474- if not isinstance (comparator , ast .Constant ) or not isinstance (
1475- comparator .value , int
1474+ if (
1475+ not isinstance (comparator , ast .Constant )
1476+ or type (comparator .value ) is not int
14761477 ):
14771478 self .error (node , Y003 )
14781479 elif not isinstance (comparator , ast .Tuple ):
Original file line number Diff line number Diff line change 11import sys
22
33if sys .version_info [0 ] == 2 : ...
4+ if sys .version_info [0 ] == True : ... # Y003 Unrecognized sys.version_info check # E712 comparison to True should be 'if cond is True:' or 'if cond:'
45if sys .version_info [0.0 ] == 2 : ... # Y003 Unrecognized sys.version_info check
6+ if sys .version_info [False ] == 2 : ... # Y003 Unrecognized sys.version_info check
57if sys .version_info [0j ] == 2 : ... # Y003 Unrecognized sys.version_info check
68if sys .version_info [0 ] == (2 , 7 ): ... # Y003 Unrecognized sys.version_info check
79if sys .version_info [0 ] == '2' : ... # Y003 Unrecognized sys.version_info check
810if sys .version_info [1 :] >= (7 , 11 ): ... # Y003 Unrecognized sys.version_info check
911if sys .version_info [::- 1 ] < (11 , 7 ): ... # Y003 Unrecognized sys.version_info check
1012if sys .version_info [:3 ] >= (2 , 7 ): ... # Y003 Unrecognized sys.version_info check
13+ if sys .version_info [:True ] >= (2 , 7 ): ... # Y003 Unrecognized sys.version_info check
1114if sys .version_info [:1 ] == (2 ,): ...
15+ if sys .version_info [:1 ] == (True ,): ... # Y003 Unrecognized sys.version_info check
1216if sys .version_info [:1 ] == (2 , 7 ): ... # Y005 Version comparison must be against a length-1 tuple
1317if sys .version_info [:2 ] == (2 , 7 ): ...
1418if sys .version_info [:2 ] == (2 ,): ... # Y005 Version comparison must be against a length-2 tuple
You can’t perform that action at this time.
0 commit comments