-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrongtopic-configurationConfiguration files and flagsConfiguration files and flagstopic-stubtest
Description
When --mypy-config-file
is passed to stubtest
is uses parse_config_file
function. Which does not handle disable_error_code
setting correctly. Since it is done in another place (mypy/main.py
):
Lines 1339 to 1353 in a0dbbd5
# Process `--enable-error-code` and `--disable-error-code` flags | |
disabled_codes = set(options.disable_error_code) | |
enabled_codes = set(options.enable_error_code) | |
valid_error_codes = set(error_codes.keys()) | |
invalid_codes = (enabled_codes | disabled_codes) - valid_error_codes | |
if invalid_codes: | |
parser.error(f"Invalid error code(s): {', '.join(sorted(invalid_codes))}") | |
options.disabled_error_codes |= {error_codes[code] for code in disabled_codes} | |
options.enabled_error_codes |= {error_codes[code] for code in enabled_codes} | |
# Enabling an error code always overrides disabling | |
options.disabled_error_codes -= options.enabled_error_codes |
There are similar cases of options that are post-processed there, but not in parse_config_file
, but let's fix them one by one to reduce potential regressions.
I propose adding process_error_codes
method to Options
object so it can be used in both main.py
and stubtest.py
(and others like stubgen
in the future).
Found while working on python/typeshed#12463
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-configurationConfiguration files and flagsConfiguration files and flagstopic-stubtest