Skip to content

Commit dd2e020

Browse files
hauntsaninjajhance
authored andcommitted
Allow stubs to use newer syntax than 3.7 (#13500)
Fixes #13499 Today this code reads like "stubs should all target 3.7" and this is indeed how typeshed operates. But authors of pyi other than typeshed should probably be allowed to choose what Python version they're targetting. Since typeshed runs checks against 3.7, this should not cause testing regressions for typeshed. This code goes back to #3000 back in the typed_ast days, when this allowed stubs to use much newer syntax features than the base Python version, so in some ways this is in the spirit of the original code.
1 parent 784d446 commit dd2e020

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

mypy/fastparse.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,8 @@ def parse(
267267
is_stub_file = fnam.endswith(".pyi")
268268
if is_stub_file:
269269
feature_version = defaults.PYTHON3_VERSION[1]
270+
if options.python_version[0] == 3 and options.python_version[1] > feature_version:
271+
feature_version = options.python_version[1]
270272
else:
271273
assert options.python_version[0] >= 3
272274
feature_version = options.python_version[1]

0 commit comments

Comments
 (0)