KEMBAR78
Consider reversed operands order when comparing version info by kamilturek · Pull Request #10288 · python/mypy · GitHub
Skip to content

Conversation

kamilturek
Copy link
Contributor

Description

Closes #10264.

Consider reversed order of operands when trying to compare version info. When reversed order is used, operator is reversed as well for correct comparison.

index = contains_sys_version_info(expr.operands[1])
thing = contains_int_or_tuple_of_ints(expr.operands[0])
op = reverse_op[op]
if index is None or thing is None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is redundant, since the conditions below won't trigger if either value is None.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right. Good point 👍

Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the redundant check.

@kamilturek
Copy link
Contributor Author

@JelleZijlstra One job on Travis CI has failed for some weird reason, doesn't look like thing related to this PR.

@JelleZijlstra
Copy link
Member

Yeah that looks harmless. I'll merge this PR, thanks for your contributions!

@JelleZijlstra JelleZijlstra merged commit 1567e36 into python:master Apr 8, 2021
@kamilturek kamilturek deleted the sys-version-comparison-order branch April 8, 2021 19:27
sthagen added a commit to sthagen/python-mypy that referenced this pull request Apr 10, 2021
Consider reversed operands order when comparing version info (python#10288)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python version check is sensitive to comparison order

2 participants