Skip to content

Commit

Permalink
Fix a crash in sys.version_info check (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
Akuli authored Jan 14, 2022
1 parent 6cfadd0 commit 3de5a0b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pyi.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,9 @@ def _check_version_check(
else:
if not isinstance(comparator, ast.Tuple):
self.error(node, Y003)
elif not all(isinstance(elt, ast.Num) for elt in comparator.elts):
return

if not all(isinstance(elt, ast.Num) for elt in comparator.elts):
self.error(node, Y003)
elif len(comparator.elts) > 2:
# mypy only supports major and minor version checks
Expand Down
3 changes: 3 additions & 0 deletions tests/sysversioninfo.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ if sys.version_info[:2] == (2, 7):
if sys.version_info[:2] == (2,): # Y005 Version comparison must be against a length-2 tuple
...

if sys.version_info[:2] == "lol": # Y003 Unrecognized sys.version_info check
...

if sys.version_info[:, :] >= (2, 7): # Y003 Unrecognized sys.version_info check
...

Expand Down

0 comments on commit 3de5a0b

Please sign in to comment.