Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a crash in sys.version_info check #59

Merged
merged 2 commits into from
Jan 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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