Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions mypy/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,11 @@ def parse_mypy_comments(
# method is to create a config parser.
parser = configparser.RawConfigParser()
options, parse_errors = mypy_comments_to_config_map(line, template)

if "python_version" in options:
errors.append((lineno, "python_version not supported in inline configuration"))
del options["python_version"]

parser["dummy"] = options
errors.extend((lineno, x) for x in parse_errors)

Expand Down
4 changes: 4 additions & 0 deletions test-data/unit/check-inline-config.test
Original file line number Diff line number Diff line change
Expand Up @@ -323,3 +323,7 @@ class Foo:
foo = Foo()
if foo: ...
42 + "no" # type: ignore


[case testInlinePythonVersion]
# mypy: python-version=3.10 # E: python_version not supported in inline configuration
Loading