Fix crash when parsing error code config with typo#16005
Merged
hauntsaninja merged 3 commits intopython:masterfrom Sep 1, 2023
Merged
Fix crash when parsing error code config with typo#16005hauntsaninja merged 3 commits intopython:masterfrom
hauntsaninja merged 3 commits intopython:masterfrom
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) |
Member
There was a problem hiding this comment.
Since we have special-case code anyway, maybe we can add a note pointing to the right version?
Suggested change
| 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) |
Collaborator
Author
There was a problem hiding this comment.
you've got an extra d :-) thanks for the suggestion!
This comment has been minimized.
This comment has been minimized.
cebtenzzre
reviewed
Sep 1, 2023
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.
Could we move the dict outside of the loop and check against e.g. key in option_replacements to avoid the repetition?
Contributor
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #16002