File tree 1 file changed +5
-3
lines changed 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -403,16 +403,18 @@ def visit_Delete(self, n: ast35.Delete) -> Node:
403
403
else :
404
404
return DelStmt (self .visit (n .targets [0 ]))
405
405
406
- # Assign(expr* targets, expr value, string ? type_comment)
406
+ # Assign(expr* targets, expr? value, expr ? type_comment)
407
407
@with_line
408
408
def visit_Assign (self , n : ast35 .Assign ) -> Node :
409
409
typ = None
410
410
if n .type_comment :
411
- if isinstance (n .type_comment , ast35 .Str ):
411
+ if isinstance (n .type_comment , str ): # backward-compatibility typed_ast
412
+ typ = parse_type_comment (n .type_comment , n .lineno )
413
+ elif isinstance (n .type_comment , ast35 .Str ):
412
414
typ = parse_type_comment (n .type_comment .s , n .lineno )
413
415
else :
414
416
typ = TypeConverter (line = n .lineno ).visit (n .type_comment )
415
- if n .value is None :
417
+ if n .value is None : # treat 'x: int' as 'x = None # type: int'
416
418
n .value = ast35 .NameConstant (value = None )
417
419
return AssignmentStmt (self .visit_list (n .targets ),
418
420
self .visit (n .value ),
You can’t perform that action at this time.
0 commit comments