Skip to content

Commit

Permalink
Fix crash when parsing error code config with typo (#16005)
Browse files Browse the repository at this point in the history
Fixes #16002
  • Loading branch information
hauntsaninja authored Sep 1, 2023
1 parent d440490 commit 803f610
Showing 1 changed file with 15 additions and 0 deletions.
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

0 comments on commit 803f610

Please sign in to comment.