168168 restrict_subtype_away ,
169169 unify_generic_callable ,
170170)
171- from mypy .traverser import TraverserVisitor , all_return_statements , has_return_statement
172171from mypy .suggestions import get_return_types
172+ from mypy .traverser import TraverserVisitor , all_return_statements , has_return_statement
173173from mypy .treetransform import TransformVisitor
174174from mypy .typeanal import check_for_explicit_any , has_any_from_unimported_type , make_optional_type
175175from mypy .typeops import (
@@ -1603,11 +1603,12 @@ def check_func_def(
16031603
16041604 # Infer return type from return statements if function has no explicit return type annotation
16051605 if isinstance (item , FuncDef ) and isinstance (typ , CallableType ):
1606+
16061607 def is_unannotated_any (t : Type ) -> bool :
16071608 if not isinstance (t , ProperType ):
16081609 return False
16091610 return isinstance (t , AnyType ) and t .type_of_any == TypeOfAny .unannotated
1610-
1611+
16111612 ret_type_proper = get_proper_type (typ .ret_type )
16121613 # Only infer for functions without explicit return type annotations
16131614 # Skip generators and coroutines as they have special return type handling
@@ -1621,7 +1622,7 @@ def is_unannotated_any(t: Type) -> bool:
16211622 # Use the master type map (first in stack) where final types are stored
16221623 # At this point in type checking, return statement types should be in the master map
16231624 return_types_list = get_return_types (self ._type_maps [0 ], item )
1624-
1625+
16251626 if return_types_list :
16261627 # Create union of all return types
16271628 inferred_ret_type = make_simplified_union (return_types_list )
0 commit comments