@@ -3958,8 +3958,10 @@ def check_and_set_up_type_alias(self, s: AssignmentStmt) -> bool:
3958
3958
# so we need to replace it with non-explicit Anys.
3959
3959
res = make_any_non_explicit (res )
3960
3960
if self .options .disallow_any_unimported and has_any_from_unimported_type (res ):
3961
- self .msg .unimported_type_becomes_any ("Type alias target" , res , s )
3962
- res = make_any_non_unimported (res )
3961
+ # Only show error message once, when the type is fully analyzed.
3962
+ if not has_placeholder (res ):
3963
+ self .msg .unimported_type_becomes_any ("Type alias target" , res , s )
3964
+ res = make_any_non_unimported (res )
3963
3965
# Note: with the new (lazy) type alias representation we only need to set no_args to True
3964
3966
# if the expected number of arguments is non-zero, so that aliases like `A = List` work
3965
3967
# but not aliases like `A = TypeAliasType("A", List)` as these need explicit type params.
@@ -4013,6 +4015,8 @@ def check_and_set_up_type_alias(self, s: AssignmentStmt) -> bool:
4013
4015
existing .node .alias_tvars = alias_tvars
4014
4016
existing .node .no_args = no_args
4015
4017
updated = True
4018
+ # Invalidate recursive status cache in case it was previously set.
4019
+ existing .node ._is_recursive = None
4016
4020
else :
4017
4021
# Otherwise just replace existing placeholder with type alias.
4018
4022
existing .node = alias_node
0 commit comments