File tree 2 files changed +16
-6
lines changed
2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -272,12 +272,12 @@ def parse(
272
272
options = Options ()
273
273
errors .set_file (fnam , module )
274
274
is_stub_file = fnam .endswith (".pyi" )
275
+ if is_stub_file :
276
+ feature_version = defaults .PYTHON3_VERSION [1 ]
277
+ else :
278
+ assert options .python_version [0 ] >= 3
279
+ feature_version = options .python_version [1 ]
275
280
try :
276
- if is_stub_file :
277
- feature_version = defaults .PYTHON3_VERSION [1 ]
278
- else :
279
- assert options .python_version [0 ] >= 3
280
- feature_version = options .python_version [1 ]
281
281
# Disable deprecation warnings about \u
282
282
with warnings .catch_warnings ():
283
283
warnings .filterwarnings ("ignore" , category = DeprecationWarning )
@@ -294,10 +294,14 @@ def parse(
294
294
# start of the f-string. This would be misleading, as mypy will report the error as the
295
295
# lineno within the file.
296
296
e .lineno = None
297
+ message = e .msg
298
+ if feature_version > sys .version_info .minor and message .startswith ("invalid syntax" ):
299
+ python_version_str = f"{ options .python_version [0 ]} .{ options .python_version [1 ]} "
300
+ message += f"; you likely need to run mypy using Python { python_version_str } or newer"
297
301
errors .report (
298
302
e .lineno if e .lineno is not None else - 1 ,
299
303
e .offset ,
300
- e . msg ,
304
+ message ,
301
305
blocker = True ,
302
306
code = codes .SYNTAX ,
303
307
)
Original file line number Diff line number Diff line change @@ -151,3 +151,9 @@ v = 1
151
151
reveal_type(f'{v}') # N: Revealed type is "builtins.str"
152
152
reveal_type(f'{1}') # N: Revealed type is "builtins.str"
153
153
[builtins fixtures/f_string.pyi]
154
+
155
+ [case testFeatureVersionSuggestion]
156
+ # flags: --python-version 3.99
157
+ this is what future python looks like public static void main String[] args await goto exit
158
+ [out]
159
+ main:2: error: invalid syntax; you likely need to run mypy using Python 3.99 or newer
You can’t perform that action at this time.
0 commit comments