@@ -23,7 +23,7 @@ def __init__(self, line: int = -1, column: int = -1) -> None:
2323 self .line = line
2424 self .column = column
2525
26- def set_line (self , target : Union ['Context' , int ], column : int = None ) -> None :
26+ def set_line (self , target : Union ['Context' , int ], column : Optional [ int ] = None ) -> None :
2727 """If target is a node, pull line (and column) information
2828 into this node. If column is specified, this will override any column
2929 information coming from a node.
@@ -254,7 +254,7 @@ def __init__(self,
254254 defs : List [Statement ],
255255 imports : List ['ImportBase' ],
256256 is_bom : bool = False ,
257- ignored_lines : Set [int ] = None ) -> None :
257+ ignored_lines : Optional [ Set [int ] ] = None ) -> None :
258258 self .defs = defs
259259 self .line = 1 # Dummy line number
260260 self .imports = imports
@@ -445,7 +445,7 @@ class Argument(Node):
445445
446446 def __init__ (self , variable : 'Var' , type_annotation : 'Optional[mypy.types.Type]' ,
447447 initializer : Optional [Expression ], kind : int ,
448- initialization_statement : Optional [' AssignmentStmt' ] = None ) -> None :
448+ initialization_statement : ' Optional[AssignmentStmt]' = None ) -> None :
449449 self .variable = variable
450450
451451 self .type_annotation = type_annotation
@@ -457,7 +457,7 @@ def __init__(self, variable: 'Var', type_annotation: 'Optional[mypy.types.Type]'
457457
458458 self .kind = kind
459459
460- def _initialization_statement (self ) -> Optional [' AssignmentStmt' ] :
460+ def _initialization_statement (self ) -> ' Optional[AssignmentStmt]' :
461461 """Convert the initializer into an assignment statement.
462462 """
463463 if not self .initializer :
@@ -468,7 +468,7 @@ def _initialization_statement(self) -> Optional['AssignmentStmt']:
468468 assign = AssignmentStmt ([lvalue ], rvalue )
469469 return assign
470470
471- def set_line (self , target : Union [Context , int ], column : int = None ) -> None :
471+ def set_line (self , target : Union [Context , int ], column : Optional [ int ] = None ) -> None :
472472 super ().set_line (target , column )
473473
474474 if self .initializer :
@@ -507,7 +507,7 @@ class FuncItem(FuncBase):
507507 ]
508508
509509 def __init__ (self , arguments : List [Argument ], body : 'Block' ,
510- typ : 'mypy.types.FunctionLike' = None ) -> None :
510+ typ : 'Optional[ mypy.types.FunctionLike] ' = None ) -> None :
511511 self .arguments = arguments
512512 self .arg_names = [arg .variable .name () for arg in self .arguments ]
513513 self .arg_kinds = [arg .kind for arg in self .arguments ]
@@ -525,7 +525,7 @@ def __init__(self, arguments: List[Argument], body: 'Block',
525525 def max_fixed_argc (self ) -> int :
526526 return self .max_pos
527527
528- def set_line (self , target : Union [Context , int ], column : int = None ) -> None :
528+ def set_line (self , target : Union [Context , int ], column : Optional [ int ] = None ) -> None :
529529 super ().set_line (target , column )
530530 for arg in self .arguments :
531531 arg .set_line (self .line , self .column )
@@ -554,7 +554,7 @@ def __init__(self,
554554 name : str , # Function name
555555 arguments : List [Argument ],
556556 body : 'Block' ,
557- typ : 'mypy.types.FunctionLike' = None ) -> None :
557+ typ : 'Optional[ mypy.types.FunctionLike] ' = None ) -> None :
558558 super ().__init__ (arguments , body , typ )
559559 self ._name = name
560560
@@ -679,7 +679,7 @@ class Var(SymbolNode):
679679 'is_classvar'
680680 ]
681681
682- def __init__ (self , name : str , type : 'mypy.types.Type' = None ) -> None :
682+ def __init__ (self , name : str , type : 'Optional[ mypy.types.Type] ' = None ) -> None :
683683 self ._name = name
684684 self .type = type
685685 if self .type is None :
@@ -738,10 +738,10 @@ class ClassDef(Statement):
738738 def __init__ (self ,
739739 name : str ,
740740 defs : 'Block' ,
741- type_vars : List ['mypy.types.TypeVarDef' ] = None ,
742- base_type_exprs : List [Expression ] = None ,
743- metaclass : str = None ,
744- keywords : List [Tuple [str , Expression ]] = None ) -> None :
741+ type_vars : Optional [ List ['mypy.types.TypeVarDef' ] ] = None ,
742+ base_type_exprs : Optional [ List [Expression ] ] = None ,
743+ metaclass : Optional [ str ] = None ,
744+ keywords : Optional [ List [Tuple [str , Expression ] ]] = None ) -> None :
745745 self .name = name
746746 self .defs = defs
747747 self .type_vars = type_vars or []
@@ -848,7 +848,7 @@ class AssignmentStmt(Statement):
848848 new_syntax = False # type: bool
849849
850850 def __init__ (self , lvalues : List [Lvalue ], rvalue : Expression ,
851- type : 'mypy.types.Type' = None , new_syntax : bool = False ) -> None :
851+ type : 'Optional[ mypy.types.Type] ' = None , new_syntax : bool = False ) -> None :
852852 self .lvalues = lvalues
853853 self .rvalue = rvalue
854854 self .type = type
@@ -900,8 +900,12 @@ class ForStmt(Statement):
900900 else_body = None # type: Optional[Block]
901901 is_async = False # True if `async for ...` (PEP 492, Python 3.5)
902902
903- def __init__ (self , index : Lvalue , expr : Expression , body : Block ,
904- else_body : Optional [Block ], index_type : 'mypy.types.Type' = None ) -> None :
903+ def __init__ (self ,
904+ index : Lvalue ,
905+ expr : Expression ,
906+ body : Block ,
907+ else_body : Optional [Block ],
908+ index_type : 'Optional[mypy.types.Type]' = None ) -> None :
905909 self .index = index
906910 self .index_type = index_type
907911 self .expr = expr
@@ -926,7 +930,7 @@ class AssertStmt(Statement):
926930 expr = None # type: Expression
927931 msg = None # type: Optional[Expression]
928932
929- def __init__ (self , expr : Expression , msg : Expression = None ) -> None :
933+ def __init__ (self , expr : Expression , msg : Optional [ Expression ] = None ) -> None :
930934 self .expr = expr
931935 self .msg = msg
932936
@@ -996,7 +1000,7 @@ class TryStmt(Statement):
9961000 else_body = None # type: Optional[Block]
9971001 finally_body = None # type: Optional[Block]
9981002
999- def __init__ (self , body : Block , vars : List [Optional [' NameExpr' ] ],
1003+ def __init__ (self , body : Block , vars : List [' Optional[NameExpr]' ],
10001004 types : List [Optional [Expression ]],
10011005 handlers : List [Block ], else_body : Optional [Block ],
10021006 finally_body : Optional [Block ]) -> None :
@@ -1020,7 +1024,7 @@ class WithStmt(Statement):
10201024 is_async = False # True if `async with ...` (PEP 492, Python 3.5)
10211025
10221026 def __init__ (self , expr : List [Expression ], target : List [Optional [Lvalue ]],
1023- body : Block , target_type : 'mypy.types.Type' = None ) -> None :
1027+ body : Block , target_type : 'Optional[ mypy.types.Type] ' = None ) -> None :
10241028 self .expr = expr
10251029 self .target = target
10261030 self .target_type = target_type
@@ -1038,7 +1042,10 @@ class PrintStmt(Statement):
10381042 # The file-like target object (given using >>).
10391043 target = None # type: Optional[Expression]
10401044
1041- def __init__ (self , args : List [Expression ], newline : bool , target : Expression = None ) -> None :
1045+ def __init__ (self ,
1046+ args : List [Expression ],
1047+ newline : bool ,
1048+ target : Optional [Expression ] = None ) -> None :
10421049 self .args = args
10431050 self .newline = newline
10441051 self .target = target
@@ -1292,8 +1299,12 @@ class CallExpr(Expression):
12921299 # cast(...) this is a CastExpr.
12931300 analyzed = None # type: Optional[Expression]
12941301
1295- def __init__ (self , callee : Expression , args : List [Expression ], arg_kinds : List [int ],
1296- arg_names : List [Optional [str ]] = None , analyzed : Expression = None ) -> None :
1302+ def __init__ (self ,
1303+ callee : Expression ,
1304+ args : List [Expression ],
1305+ arg_kinds : List [int ],
1306+ arg_names : Optional [List [Optional [str ]]] = None ,
1307+ analyzed : Optional [Expression ] = None ) -> None :
12971308 if not arg_names :
12981309 arg_names = [None ] * len (args )
12991310
@@ -1813,7 +1824,7 @@ class TypeAliasExpr(Expression):
18131824 in_runtime = False # type: bool
18141825
18151826 def __init__ (self , type : 'mypy.types.Type' , tvars : List [str ],
1816- fallback : 'mypy.types.Type' = None , in_runtime : bool = False ) -> None :
1827+ fallback : 'Optional[ mypy.types.Type] ' = None , in_runtime : bool = False ) -> None :
18171828 self .type = type
18181829 self .fallback = fallback
18191830 self .in_runtime = in_runtime
@@ -2038,14 +2049,14 @@ def is_generic(self) -> bool:
20382049 """Is the type generic (i.e. does it have type variables)?"""
20392050 return len (self .type_vars ) > 0
20402051
2041- def get (self , name : str ) -> Optional [' SymbolTableNode' ] :
2052+ def get (self , name : str ) -> ' Optional[SymbolTableNode]' :
20422053 for cls in self .mro :
20432054 n = cls .names .get (name )
20442055 if n :
20452056 return n
20462057 return None
20472058
2048- def get_containing_type_info (self , name : str ) -> Optional [' TypeInfo' ] :
2059+ def get_containing_type_info (self , name : str ) -> ' Optional[TypeInfo]' :
20492060 for cls in self .mro :
20502061 if name in cls .names :
20512062 return cls
@@ -2150,8 +2161,8 @@ def __str__(self) -> str:
21502161 return self .dump ()
21512162
21522163 def dump (self ,
2153- str_conv : 'mypy.strconv.StrConv' = None ,
2154- type_str_conv : 'mypy.types.TypeStrVisitor' = None ) -> str :
2164+ str_conv : 'Optional[ mypy.strconv.StrConv] ' = None ,
2165+ type_str_conv : 'Optional[ mypy.types.TypeStrVisitor] ' = None ) -> str :
21552166 """Return a string dump of the contents of the TypeInfo."""
21562167 if not str_conv :
21572168 str_conv = mypy .strconv .StrConv ()
@@ -2282,9 +2293,13 @@ class SymbolTableNode:
22822293 # Was this defined by assignment to self attribute?
22832294 implicit = False # type: bool
22842295
2285- def __init__ (self , kind : int , node : Optional [SymbolNode ], mod_id : str = None ,
2286- typ : 'mypy.types.Type' = None ,
2287- module_public : bool = True , normalized : bool = False ,
2296+ def __init__ (self ,
2297+ kind : int ,
2298+ node : Optional [SymbolNode ],
2299+ mod_id : Optional [str ] = None ,
2300+ typ : 'Optional[mypy.types.Type]' = None ,
2301+ module_public : bool = True ,
2302+ normalized : bool = False ,
22882303 alias_tvars : Optional [List [str ]] = None ,
22892304 implicit : bool = False ) -> None :
22902305 self .kind = kind
0 commit comments