Skip to content
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

Merged
merged 3 commits into from
Sep 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions mypy/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,11 +434,26 @@ def parse_section(
"""
results: dict[str, object] = {}
report_dirs: dict[str, str] = {}

# Because these fields exist on Options, without proactive checking, we would accept them
# and crash later
invalid_options = {
"enabled_error_codes": "enable_error_code",
"disabled_error_codes": "disable_error_code",
}

for key in section:
invert = False
options_key = key
if key in config_types:
ct = config_types[key]
elif key in invalid_options:
print(
f"{prefix}Unrecognized option: {key} = {section[key]}"
f" (did you mean {invalid_options[key]}?)",
file=stderr,
)
continue
else:
dv = None
# We have to keep new_semantic_analyzer in Options
Expand Down