-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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 crash when parsing error code config with typo #16005
Conversation
This comment has been minimized.
This comment has been minimized.
mypy/config_parser.py
Outdated
elif key in ("enabled_error_codes", "disabled_error_codes"): | ||
# These should be "enable_error_code" and "disable_error_code". But because these fields | ||
# exist on Options, we would otherwise accept them here and crash later. | ||
print(f"{prefix}Unrecognized option: {key} = {section[key]}", file=stderr) |
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.
Since we have special-case code anyway, maybe we can add a note pointing to the right version?
print(f"{prefix}Unrecognized option: {key} = {section[key]}", file=stderr) | |
print(f"{prefix}Unrecognized option: {key} = {section[key]} (did you mean {key[:-1]!r}?)", file=stderr) |
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.
you've got an extra d :-) thanks for the suggestion!
This comment has been minimized.
This comment has been minimized.
mypy/config_parser.py
Outdated
suggestion = { | ||
"enabled_error_codes": "enable_error_code", | ||
"disabled_error_codes": "disable_error_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.
Could we move the dict outside of the loop and check against e.g. key in option_replacements
to avoid the repetition?
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
Fixes #16002