-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Add check if python_version was parsed as float in pyproject.toml #12558
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
Add check if python_version was parsed as float in pyproject.toml #12558
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Can we move this check inside parse_version
? We could also maybe give a more helpful message. E.g. something like
if minor < defaults.PYTHON3_VERSION_MIN[1]:
msg = "..."
if isinstance(s, float):
msg += "You may need to put quotes around your version"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
This comment has been minimized.
This comment has been minimized.
2 similar comments
This comment has been minimized.
This comment has been minimized.
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Fixes #12108
Passing
python_version = 3.10
in a toml file without quotes gives this error messageThis happens because the argument is parsed as a float and is converted into a string in mypy code, turning 3.10 into '3.1'. For other version like 3.8 this isn't a problem since it doesn't end in a zero.
I decided to leave python versions that don't end in a zero without error message, since it doesn't seem to have any problems regarding those cases. But for 3.10 a more clear message should leave fewer people confused about this specific issue.
Test Plan
Added a test for the case of
python_version = 3.10
with the expected message at cmdline.test.