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