diff --git a/mypy/build.py b/mypy/build.py index f8a9294ebd766..525d5f436e7e1 100644 --- a/mypy/build.py +++ b/mypy/build.py @@ -2207,7 +2207,6 @@ def parse_inline_configuration(self, source: str) -> None: """Check for inline mypy: options directive and parse them.""" flags = get_mypy_comments(source) if flags: - # TODO: should this be captured as well for parser errors? changes, config_errors = parse_mypy_comments(flags, self.options) self.options = self.options.apply_changes(changes) self.manager.errors.set_file(self.xpath, self.id, self.options) diff --git a/mypy/config_parser.py b/mypy/config_parser.py index f6c889c9de96b..371c9bd898d7b 100644 --- a/mypy/config_parser.py +++ b/mypy/config_parser.py @@ -454,7 +454,7 @@ def parse_section( else: msg = f"{prefix}Unrecognized report type: {key}" raise argparse.ArgumentTypeError(msg) - if key.startswith("x_"): + elif key.startswith("x_"): pass # Don't complain about `x_blah` flags elif key.startswith("no_") and hasattr(template, key[3:]): options_key = key[3:] @@ -489,7 +489,6 @@ def parse_section( v = not v elif callable(ct): if invert: - # TODO: should this be captured or it is okay to ignore print(f"{prefix}Can not invert non-boolean key {options_key}", file=stderr) continue try: @@ -499,7 +498,6 @@ def parse_section( raise argparse.ArgumentTypeError(msg) from err else: print(f"{prefix}Don't know what type {key} should have", file=stderr) - # TODO: should this be captured or it is okay to ignore as type is not known continue except ValueError as err: msg = f"{prefix}{key}: {err}" diff --git a/mypy/main.py b/mypy/main.py index 329bfe51c061f..2de206074c6b9 100644 --- a/mypy/main.py +++ b/mypy/main.py @@ -1252,8 +1252,7 @@ def set_strict_flags() -> None: try: parse_config_file(options, set_strict_flags, config_file, stdout, stderr) except (argparse.ArgumentTypeError, ValueError) as err: - stderr.write(f"{err}") - sys.exit(1) + raise SystemExit(str(err)) from err # Set strict flags before parsing (if strict mode enabled), so other command # line options can override.