-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Fix #19491, crash when using enable_error_code value of wrong type in pyproject.toml #19494
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
base: master
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Stanislav Terliakov <50529348+sterliakov@users.noreply.github.com>
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
This comment has been minimized.
This comment has been minimized.
The fact that we're now raising an error instead of allowing the value to go through and yet the test apparently still passes makes me wonder if the test is wrong. Or maybe I just got lucky and the implications of raising an error result in the same error message and thus pass the test the same way. |
This comment has been minimized.
This comment has been minimized.
Ah, this should be object, not Any, shouldn't it? And while I'm at it, I can simplify the split regex
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
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.
Looks great, thanks!
Fixes #19491
If you give a string in toml, you get Invalid error code(s): whatever. However, if you give a value that doesn't mean a string in toml, you get a crash like TypeError: 'int' object is not iterable.
I suspect this would also apply to many other pyproject.toml values if you set them wrong, because we pass many of them immediately into try_split, which tries to iterate them.
I have added a (fairly minimal) test for this behavior.