@@ -23,7 +23,7 @@ def __init__(self, line: int = -1, column: int = -1) -> None:
23
23
self .line = line
24
24
self .column = column
25
25
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 :
27
27
"""If target is a node, pull line (and column) information
28
28
into this node. If column is specified, this will override any column
29
29
information coming from a node.
@@ -254,7 +254,7 @@ def __init__(self,
254
254
defs : List [Statement ],
255
255
imports : List ['ImportBase' ],
256
256
is_bom : bool = False ,
257
- ignored_lines : Set [int ] = None ) -> None :
257
+ ignored_lines : Optional [ Set [int ] ] = None ) -> None :
258
258
self .defs = defs
259
259
self .line = 1 # Dummy line number
260
260
self .imports = imports
@@ -445,7 +445,7 @@ class Argument(Node):
445
445
446
446
def __init__ (self , variable : 'Var' , type_annotation : 'Optional[mypy.types.Type]' ,
447
447
initializer : Optional [Expression ], kind : int ,
448
- initialization_statement : Optional [' AssignmentStmt' ] = None ) -> None :
448
+ initialization_statement : ' Optional[AssignmentStmt]' = None ) -> None :
449
449
self .variable = variable
450
450
451
451
self .type_annotation = type_annotation
@@ -457,7 +457,7 @@ def __init__(self, variable: 'Var', type_annotation: 'Optional[mypy.types.Type]'
457
457
458
458
self .kind = kind
459
459
460
- def _initialization_statement (self ) -> Optional [' AssignmentStmt' ] :
460
+ def _initialization_statement (self ) -> ' Optional[AssignmentStmt]' :
461
461
"""Convert the initializer into an assignment statement.
462
462
"""
463
463
if not self .initializer :
@@ -468,7 +468,7 @@ def _initialization_statement(self) -> Optional['AssignmentStmt']:
468
468
assign = AssignmentStmt ([lvalue ], rvalue )
469
469
return assign
470
470
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 :
472
472
super ().set_line (target , column )
473
473
474
474
if self .initializer :
@@ -507,7 +507,7 @@ class FuncItem(FuncBase):
507
507
]
508
508
509
509
def __init__ (self , arguments : List [Argument ], body : 'Block' ,
510
- typ : 'mypy.types.FunctionLike' = None ) -> None :
510
+ typ : 'Optional[ mypy.types.FunctionLike] ' = None ) -> None :
511
511
self .arguments = arguments
512
512
self .arg_names = [arg .variable .name () for arg in self .arguments ]
513
513
self .arg_kinds = [arg .kind for arg in self .arguments ]
@@ -525,7 +525,7 @@ def __init__(self, arguments: List[Argument], body: 'Block',
525
525
def max_fixed_argc (self ) -> int :
526
526
return self .max_pos
527
527
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 :
529
529
super ().set_line (target , column )
530
530
for arg in self .arguments :
531
531
arg .set_line (self .line , self .column )
@@ -554,7 +554,7 @@ def __init__(self,
554
554
name : str , # Function name
555
555
arguments : List [Argument ],
556
556
body : 'Block' ,
557
- typ : 'mypy.types.FunctionLike' = None ) -> None :
557
+ typ : 'Optional[ mypy.types.FunctionLike] ' = None ) -> None :
558
558
super ().__init__ (arguments , body , typ )
559
559
self ._name = name
560
560
@@ -679,7 +679,7 @@ class Var(SymbolNode):
679
679
'is_classvar'
680
680
]
681
681
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 :
683
683
self ._name = name
684
684
self .type = type
685
685
if self .type is None :
@@ -738,10 +738,10 @@ class ClassDef(Statement):
738
738
def __init__ (self ,
739
739
name : str ,
740
740
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 :
745
745
self .name = name
746
746
self .defs = defs
747
747
self .type_vars = type_vars or []
@@ -848,7 +848,7 @@ class AssignmentStmt(Statement):
848
848
new_syntax = False # type: bool
849
849
850
850
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 :
852
852
self .lvalues = lvalues
853
853
self .rvalue = rvalue
854
854
self .type = type
@@ -900,8 +900,12 @@ class ForStmt(Statement):
900
900
else_body = None # type: Optional[Block]
901
901
is_async = False # True if `async for ...` (PEP 492, Python 3.5)
902
902
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 :
905
909
self .index = index
906
910
self .index_type = index_type
907
911
self .expr = expr
@@ -926,7 +930,7 @@ class AssertStmt(Statement):
926
930
expr = None # type: Expression
927
931
msg = None # type: Optional[Expression]
928
932
929
- def __init__ (self , expr : Expression , msg : Expression = None ) -> None :
933
+ def __init__ (self , expr : Expression , msg : Optional [ Expression ] = None ) -> None :
930
934
self .expr = expr
931
935
self .msg = msg
932
936
@@ -996,7 +1000,7 @@ class TryStmt(Statement):
996
1000
else_body = None # type: Optional[Block]
997
1001
finally_body = None # type: Optional[Block]
998
1002
999
- def __init__ (self , body : Block , vars : List [Optional [' NameExpr' ] ],
1003
+ def __init__ (self , body : Block , vars : List [' Optional[NameExpr]' ],
1000
1004
types : List [Optional [Expression ]],
1001
1005
handlers : List [Block ], else_body : Optional [Block ],
1002
1006
finally_body : Optional [Block ]) -> None :
@@ -1020,7 +1024,7 @@ class WithStmt(Statement):
1020
1024
is_async = False # True if `async with ...` (PEP 492, Python 3.5)
1021
1025
1022
1026
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 :
1024
1028
self .expr = expr
1025
1029
self .target = target
1026
1030
self .target_type = target_type
@@ -1038,7 +1042,10 @@ class PrintStmt(Statement):
1038
1042
# The file-like target object (given using >>).
1039
1043
target = None # type: Optional[Expression]
1040
1044
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 :
1042
1049
self .args = args
1043
1050
self .newline = newline
1044
1051
self .target = target
@@ -1292,8 +1299,12 @@ class CallExpr(Expression):
1292
1299
# cast(...) this is a CastExpr.
1293
1300
analyzed = None # type: Optional[Expression]
1294
1301
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 :
1297
1308
if not arg_names :
1298
1309
arg_names = [None ] * len (args )
1299
1310
@@ -1813,7 +1824,7 @@ class TypeAliasExpr(Expression):
1813
1824
in_runtime = False # type: bool
1814
1825
1815
1826
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 :
1817
1828
self .type = type
1818
1829
self .fallback = fallback
1819
1830
self .in_runtime = in_runtime
@@ -2038,14 +2049,14 @@ def is_generic(self) -> bool:
2038
2049
"""Is the type generic (i.e. does it have type variables)?"""
2039
2050
return len (self .type_vars ) > 0
2040
2051
2041
- def get (self , name : str ) -> Optional [' SymbolTableNode' ] :
2052
+ def get (self , name : str ) -> ' Optional[SymbolTableNode]' :
2042
2053
for cls in self .mro :
2043
2054
n = cls .names .get (name )
2044
2055
if n :
2045
2056
return n
2046
2057
return None
2047
2058
2048
- def get_containing_type_info (self , name : str ) -> Optional [' TypeInfo' ] :
2059
+ def get_containing_type_info (self , name : str ) -> ' Optional[TypeInfo]' :
2049
2060
for cls in self .mro :
2050
2061
if name in cls .names :
2051
2062
return cls
@@ -2150,8 +2161,8 @@ def __str__(self) -> str:
2150
2161
return self .dump ()
2151
2162
2152
2163
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 :
2155
2166
"""Return a string dump of the contents of the TypeInfo."""
2156
2167
if not str_conv :
2157
2168
str_conv = mypy .strconv .StrConv ()
@@ -2282,9 +2293,13 @@ class SymbolTableNode:
2282
2293
# Was this defined by assignment to self attribute?
2283
2294
implicit = False # type: bool
2284
2295
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 ,
2288
2303
alias_tvars : Optional [List [str ]] = None ,
2289
2304
implicit : bool = False ) -> None :
2290
2305
self .kind = kind
0 commit comments