@@ -4014,8 +4014,10 @@ def check_and_set_up_type_alias(self, s: AssignmentStmt) -> bool:
40144014 # so we need to replace it with non-explicit Anys.
40154015 res = make_any_non_explicit (res )
40164016 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 )
40194021 # Note: with the new (lazy) type alias representation we only need to set no_args to True
40204022 # if the expected number of arguments is non-zero, so that aliases like `A = List` work
40214023 # 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:
40694071 existing .node .alias_tvars = alias_tvars
40704072 existing .node .no_args = no_args
40714073 updated = True
4074+ # Invalidate recursive status cache in case it was previously set.
4075+ existing .node ._is_recursive = None
40724076 else :
40734077 # Otherwise just replace existing placeholder with type alias.
40744078 existing .node = alias_node
0 commit comments