File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -206,13 +206,15 @@ def parse(
206206 options = Options ()
207207 errors .set_file (fnam , module , options = options )
208208 is_stub_file = fnam .endswith (".pyi" )
209- if is_stub_file :
209+ if ignore_errors :
210+ feature_version = sys .version_info [1 ]
211+ elif is_stub_file :
210212 feature_version = defaults .PYTHON3_VERSION [1 ]
211- if options .python_version [0 ] == 3 and options .python_version [1 ] > feature_version :
212- feature_version = options .python_version [1 ]
213213 else :
214214 assert options .python_version [0 ] >= 3
215215 feature_version = options .python_version [1 ]
216+ if options .python_version [0 ] == 3 and options .python_version [1 ] > feature_version :
217+ feature_version = options .python_version [1 ]
216218 try :
217219 # Disable
218220 # - deprecation warnings for 'invalid escape sequence' (Python 3.11 and below)
Original file line number Diff line number Diff line change @@ -158,8 +158,8 @@ def _item_fail(msg: str) -> NoReturn:
158158 for arg in args :
159159 if arg .startswith ("version" ):
160160 compare_op = arg [7 :9 ]
161- if compare_op not in {">=" , "==" }:
162- _item_fail ("Only >= and == version checks are currently supported" )
161+ if compare_op not in {">=" , "==" , "< " }:
162+ _item_fail ("Only `>=', `==', and `< ' version checks are currently supported" )
163163 version_str = arg [9 :]
164164 try :
165165 version = tuple (int (x ) for x in version_str .split ("." ))
@@ -181,6 +181,12 @@ def _item_fail(msg: str) -> NoReturn:
181181 f'Only minor or patch version checks are currently supported with "==": { version_str !r} '
182182 )
183183 version_check = sys .version_info [: len (version )] == version
184+ elif compare_op == "< " :
185+ if version < defaults .PYTHON3_VERSION :
186+ _item_fail (
187+ f"{ arg } always false since minimum runtime version is { defaults .PYTHON3_VERSION } "
188+ )
189+ version_check = sys .version_info < version
184190 if version_check :
185191 tmp_output = [expand_variables (line ) for line in item .data ]
186192 if os .path .sep == "\\ " and case .normalize_output :
Original file line number Diff line number Diff line change @@ -475,3 +475,10 @@ x = 1 # type: ignore # E: Unused "type: ignore" comment
475475x = 1 # type: ignore # E: Unused "type: ignore" comment
476476[out]
477477main:2: error: Unrecognized option: amongus = True
478+
479+ [case testNewSyntaxOldMypy]
480+ # flags: --python-version 3.10
481+ # mypy: ignore-errors=True
482+ x = t""
483+ [out version< 3.14]
484+ main:3: error: Invalid syntax
You can’t perform that action at this time.
0 commit comments