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
@@ -1623,7 +1624,7 @@ def is_unannotated_any(t: Type) -> bool:
16231624 for type_map in self ._type_maps :
16241625 return_types_list = get_return_types (type_map , item )
16251626 all_return_types .extend (return_types_list )
1626-
1627+
16271628 if all_return_types :
16281629 # Create union of all return types
16291630 inferred_ret_type = make_simplified_union (all_return_types )
0 commit comments