@@ -180,6 +180,8 @@ def check_first_pass(self) -> None:
180180
181181 all_ = self .globals .get ('__all__' )
182182 if all_ is not None and all_ .type is not None :
183+ all_node = all_ .node
184+ assert all_node is not None
183185 seq_str = self .named_generic_type ('typing.Sequence' ,
184186 [self .named_type ('builtins.str' )])
185187 if self .options .python_version [0 ] < 3 :
@@ -188,7 +190,7 @@ def check_first_pass(self) -> None:
188190 if not is_subtype (all_ .type , seq_str ):
189191 str_seq_s , all_s = self .msg .format_distinctly (seq_str , all_ .type )
190192 self .fail (messages .ALL_MUST_BE_SEQ_STR .format (str_seq_s , all_s ),
191- all_ . node )
193+ all_node )
192194
193195 def check_second_pass (self , todo : List [DeferredNode ] = None ) -> bool :
194196 """Run second or following pass of type checking.
@@ -346,12 +348,13 @@ def check_overlapping_overloads(self, defn: OverloadedFuncDef) -> None:
346348 self .msg .overloaded_signatures_arg_specific (i + 1 , defn .impl )
347349 impl_type_subst = impl_type
348350 if impl_type .variables :
349- impl_type_subst = unify_generic_callable (impl_type , sig1 , ignore_return = False )
350- if impl_type_subst is None :
351+ unified = unify_generic_callable (impl_type , sig1 , ignore_return = False )
352+ if unified is None :
351353 self .fail ("Type variable mismatch between " +
352354 "overload signature {} and implementation" .format (i + 1 ),
353355 defn .impl )
354356 return
357+ impl_type_subst = unified
355358 if not is_subtype (sig1 .ret_type , impl_type_subst .ret_type ):
356359 self .msg .overloaded_signatures_ret_specific (i + 1 , defn .impl )
357360
@@ -593,7 +596,7 @@ def check_func_def(self, defn: FuncItem, typ: CallableType, name: str) -> None:
593596 not isinstance (typ .ret_type , NoneTyp ) and
594597 not self .dynamic_funcs [- 1 ]):
595598 self .fail (messages .MUST_HAVE_NONE_RETURN_TYPE .format (fdef .name ()),
596- item . type )
599+ item )
597600
598601 show_untyped = not self .is_typeshed_stub or self .options .warn_incomplete_stub
599602 if self .options .disallow_untyped_defs and show_untyped :
@@ -1257,7 +1260,7 @@ def check_assignment(self, lvalue: Lvalue, rvalue: Expression, infer_lvalue_type
12571260 self .infer_variable_type (inferred , lvalue , self .expr_checker .accept (rvalue ),
12581261 rvalue )
12591262
1260- def check_compatibility_all_supers (self , lvalue : NameExpr , lvalue_type : Type ,
1263+ def check_compatibility_all_supers (self , lvalue : NameExpr , lvalue_type : Optional [ Type ] ,
12611264 rvalue : Expression ) -> bool :
12621265 lvalue_node = lvalue .node
12631266
@@ -1300,8 +1303,9 @@ def check_compatibility_all_supers(self, lvalue: NameExpr, lvalue_type: Type,
13001303 break
13011304 return False
13021305
1303- def check_compatibility_super (self , lvalue : NameExpr , lvalue_type : Type , rvalue : Expression ,
1304- base : TypeInfo , base_type : Type , base_node : Node ) -> bool :
1306+ def check_compatibility_super (self , lvalue : NameExpr , lvalue_type : Optional [Type ],
1307+ rvalue : Expression , base : TypeInfo , base_type : Type ,
1308+ base_node : Node ) -> bool :
13051309 lvalue_node = lvalue .node
13061310 assert isinstance (lvalue_node , Var )
13071311
@@ -1574,10 +1578,12 @@ def check_multi_assignment_from_iterable(self, lvalues: List[Lvalue], rvalue_typ
15741578 else :
15751579 self .msg .type_not_iterable (rvalue_type , context )
15761580
1577- def check_lvalue (self , lvalue : Lvalue ) -> Tuple [Type , IndexExpr , Var ]:
1578- lvalue_type = None # type: Type
1579- index_lvalue = None # type: IndexExpr
1580- inferred = None # type: Var
1581+ def check_lvalue (self , lvalue : Lvalue ) -> Tuple [Optional [Type ],
1582+ Optional [IndexExpr ],
1583+ Optional [Var ]]:
1584+ lvalue_type = None # type: Optional[Type]
1585+ index_lvalue = None # type: Optional[IndexExpr]
1586+ inferred = None # type: Optional[Var]
15811587
15821588 if self .is_definition (lvalue ):
15831589 if isinstance (lvalue , NameExpr ):
@@ -2750,8 +2756,8 @@ def find_isinstance_check(node: Expression,
27502756 # Check for `x is None` and `x is not None`.
27512757 is_not = node .operators == ['is not' ]
27522758 if any (is_literal_none (n ) for n in node .operands ) and (is_not or node .operators == ['is' ]):
2753- if_vars = {} # type: Dict[Expression, Type]
2754- else_vars = {} # type: Dict[Expression, Type]
2759+ if_vars = {} # type: TypeMap
2760+ else_vars = {} # type: TypeMap
27552761 for expr in node .operands :
27562762 if expr .literal == LITERAL_TYPE and not is_literal_none (expr ) and expr in type_map :
27572763 # This should only be true at most once: there should be
@@ -2829,7 +2835,8 @@ def flatten_types(t: Type) -> List[Type]:
28292835 return [t ]
28302836
28312837
2832- def get_isinstance_type (expr : Expression , type_map : Dict [Expression , Type ]) -> List [TypeRange ]:
2838+ def get_isinstance_type (expr : Expression ,
2839+ type_map : Dict [Expression , Type ]) -> Optional [List [TypeRange ]]:
28332840 all_types = flatten_types (type_map [expr ])
28342841 types = [] # type: List[TypeRange]
28352842 for typ in all_types :
0 commit comments