8000 Fix crash when parsing error code config with typo (#16005) · python/mypy@803f610 · GitHub
[go: up one dir, main page]

Skip to content

Commit 803f610

Browse files
authored
Fix crash when parsing error code config with typo (#16005)
Fixes #16002
1 parent d440490 commit 803f610

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

mypy/config_parser.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,11 +434,26 @@ def parse_section(
434434
"""
435435
results: dict[str, object] = {}
436436
report_dirs: dict[str, str] = {}
437+
438+
# Because these fields exist on Options, without proactive checking, we would accept them
439+
# and crash later
440+
invalid_options = {
441+
"enabled_error_codes": "enable_error_code",
442+
"disabled_error_codes": "disable_error_code",
443+
}
444+
437445
for key in section:
438446
invert = False
439447
options_key = key
440448
if key in config_types:
441449
ct = config_types[key]
450+
elif key in invalid_options:
451+
print(
452+
f"{prefix}Unrecognized option: {key} = {section[key]}"
453+
f" (did you mean {invalid_options[key]}?)",
454+
file=stderr,
455+
)
456+
continue
442457
else:
443458
dv = None
444459
# We have to keep new_semantic_analyzer in Options

0 commit comments

Comments
 (0)
0