273273 get_proper_types ,
274274 invalid_recursive_alias ,
275275 is_named_instance ,
276+ store_argument_type ,
276277)
277278from mypy .typevars import fill_typevars
278279from mypy .util import (
@@ -1315,7 +1316,10 @@ def analyze_function_body(self, defn: FuncItem) -> None:
13151316 # Bind the type variables again to visit the body.
13161317 if defn .type :
13171318 a = self .type_analyzer ()
1318- a .bind_function_type_variables (cast (CallableType , defn .type ), defn )
1319+ typ = cast (CallableType , defn .type )
1320+ a .bind_function_type_variables (typ , defn )
1321+ for i in range (len (typ .arg_types )):
1322+ store_argument_type (defn , i , typ , self .named_type )
13191323 self .function_stack .append (defn )
13201324 with self .enter (defn ):
13211325 for arg in defn .arguments :
@@ -2018,7 +2022,9 @@ def analyze_base_classes(
20182022 continue
20192023
20202024 try :
2021- base = self .expr_to_analyzed_type (base_expr , allow_placeholder = True )
2025+ base = self .expr_to_analyzed_type (
2026+ base_expr , allow_placeholder = True , allow_type_any = True
2027+ )
20222028 except TypeTranslationError :
20232029 name = self .get_name_repr_of_expr (base_expr )
20242030 if isinstance (base_expr , CallExpr ):
@@ -6139,7 +6145,11 @@ def accept(self, node: Node) -> None:
61396145 report_internal_error (err , self .errors .file , node .line , self .errors , self .options )
61406146
61416147 def expr_to_analyzed_type (
6142- self , expr : Expression , report_invalid_types : bool = True , allow_placeholder : bool = False
6148+ self ,
6149+ expr : Expression ,
6150+ report_invalid_types : bool = True ,
6151+ allow_placeholder : bool = False ,
6152+ allow_type_any : bool = False ,
61436153 ) -> Type | None :
61446154 if isinstance (expr , CallExpr ):
61456155 # This is a legacy syntax intended mostly for Python 2, we keep it for
@@ -6164,7 +6174,10 @@ def expr_to_analyzed_type(
61646174 return TupleType (info .tuple_type .items , fallback = fallback )
61656175 typ = self .expr_to_unanalyzed_type (expr )
61666176 return self .anal_type (
6167- typ , report_invalid_types = report_invalid_types , allow_placeholder = allow_placeholder
6177+ typ ,
6178+ report_invalid_types = report_invalid_types ,
6179+ allow_placeholder = allow_placeholder ,
6180+ allow_type_any = allow_type_any ,
61686181 )
61696182
61706183 def analyze_type_expr (self , expr : Expression ) -> None :
@@ -6188,6 +6201,7 @@ def type_analyzer(
61886201 allow_param_spec_literals : bool = False ,
61896202 report_invalid_types : bool = True ,
61906203 prohibit_self_type : str | None = None ,
6204+ allow_type_any : bool = False ,
61916205 ) -> TypeAnalyser :
61926206 if tvar_scope is None :
61936207 tvar_scope = self .tvar_scope
@@ -6204,6 +6218,7 @@ def type_analyzer(
62046218 allow_required = allow_required ,
62056219 allow_param_spec_literals = allow_param_spec_literals ,
62066220 prohibit_self_type = prohibit_self_type ,
6221+ allow_type_any = allow_type_any ,
62076222 )
62086223 tpan .in_dynamic_func = bool (self .function_stack and self .function_stack [- 1 ].is_dynamic ())
62096224 tpan .global_scope = not self .type and not self .function_stack
@@ -6224,6 +6239,7 @@ def anal_type(
62246239 allow_param_spec_literals : bool = False ,
62256240 report_invalid_types : bool = True ,
62266241 prohibit_self_type : str | None = None ,
6242+ allow_type_any : bool = False ,
62276243 third_pass : bool = False ,
62286244 ) -> Type | None :
62296245 """Semantically analyze a type.
@@ -6260,6 +6276,7 @@ def anal_type(
62606276 allow_param_spec_literals = allow_param_spec_literals ,
62616277 report_invalid_types = report_invalid_types ,
62626278 prohibit_self_type = prohibit_self_type ,
6279+ allow_type_any = allow_type_any ,
62636280 )
62646281 tag = self .track_incomplete_refs ()
62656282 typ = typ .accept (a )
0 commit comments