@@ -169,7 +169,9 @@ def parse(source: Union[str, bytes],
169
169
tree .path = fnam
170
170
tree .is_stub = is_stub_file
171
171
except SyntaxError as e :
172
- if sys .version_info < (3 , 9 ) and e .filename == "<fstring>" :
172
+ # alias to please mypyc
173
+ is_py38_or_earlier = sys .version_info < (3 , 9 )
174
+ if is_py38_or_earlier and e .filename == "<fstring>" :
173
175
# In Python 3.8 and earlier, syntax errors in f-strings have lineno relative to the
174
176
# start of the f-string. This would be misleading, as mypy will report the error as the
175
177
# lineno within the file.
@@ -1210,9 +1212,11 @@ def visit_Attribute(self, n: Attribute) -> Union[MemberExpr, SuperExpr]:
1210
1212
def visit_Subscript (self , n : ast3 .Subscript ) -> IndexExpr :
1211
1213
e = IndexExpr (self .visit (n .value ), self .visit (n .slice ))
1212
1214
self .set_line (e , n )
1215
+ # alias to please mypyc
1216
+ is_py38_or_earlier = sys .version_info < (3 , 9 )
1213
1217
if (
1214
1218
isinstance (n .slice , ast3 .Slice ) or
1215
- (sys . version_info < ( 3 , 9 ) and isinstance (n .slice , ast3 .ExtSlice ))
1219
+ (is_py38_or_earlier and isinstance (n .slice , ast3 .ExtSlice ))
1216
1220
):
1217
1221
# Before Python 3.9, Slice has no line/column in the raw ast. To avoid incompatibility
1218
1222
# visit_Slice doesn't set_line, even in Python 3.9 on.
@@ -1258,12 +1262,12 @@ def visit_Slice(self, n: ast3.Slice) -> SliceExpr:
1258
1262
# ExtSlice(slice* dims)
1259
1263
def visit_ExtSlice (self , n : ast3 .ExtSlice ) -> TupleExpr :
1260
1264
# cast for mypyc's benefit on Python 3.9
1261
- return TupleExpr (self .translate_expr_list (cast (Any , n .dims ) ))
1265
+ return TupleExpr (self .translate_expr_list (cast (Any , n ) .dims ))
1262
1266
1263
1267
# Index(expr value)
1264
1268
def visit_Index (self , n : Index ) -> Node :
1265
1269
# cast for mypyc's benefit on Python 3.9
1266
- return self .visit (cast (Any , n .value ) )
1270
+ return self .visit (cast (Any , n ) .value )
1267
1271
1268
1272
1269
1273
class TypeConverter :
0 commit comments