Skip to content

Commit cb301e3

Browse files
committed
Assert t.alias is not None before keying seen-aliases sets
1 parent b56d7ae commit cb301e3

3 files changed

Lines changed: 4 additions & 2 deletions

File tree

mypy/semanal_typeargs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ def visit_block(self, o: Block) -> None:
8585

8686
def visit_type_alias_type(self, t: TypeAliasType) -> None:
8787
super().visit_type_alias_type(t)
88+
assert t.alias is not None, f"Unfixed type alias {t.type_ref}"
8889
if t.is_recursive:
8990
if t.alias in self.seen_aliases:
9091
# Avoid infinite recursion on recursive type aliases.
9192
return
9293
self.seen_aliases.add(t.alias)
93-
assert t.alias is not None, f"Unfixed type alias {t.type_ref}"
9494
is_error, is_invalid = self.validate_args(
9595
t.alias.name, tuple(t.args), t.alias.alias_tvars, t
9696
)

mypy/server/deps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,10 +980,10 @@ def visit_instance(self, typ: Instance) -> list[str]:
980980
return triggers
981981

982982
def visit_type_alias_type(self, typ: TypeAliasType) -> list[str]:
983+
assert typ.alias is not None
983984
if typ.alias in self.seen_aliases:
984985
return []
985986
self.seen_aliases.add(typ.alias)
986-
assert typ.alias is not None
987987
trigger = make_trigger(typ.alias.fullname)
988988
triggers = [trigger]
989989
for arg in typ.args:

mypy/type_visitor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ def visit_type_alias_type(self, t: TypeAliasType, /) -> T:
456456
# Skip type aliases already visited to avoid infinite recursion.
457457
# We track by the TypeAlias node so that recursive aliases with varying
458458
# type arguments are still caught.
459+
assert t.alias is not None, f"Unfixed type alias {t.type_ref}"
459460
if self.seen_aliases is None:
460461
self.seen_aliases = set()
461462
elif t.alias in self.seen_aliases:
@@ -600,6 +601,7 @@ def visit_type_alias_type(self, t: TypeAliasType, /) -> bool:
600601
# Skip type aliases already visited to avoid infinite recursion.
601602
# We track by the TypeAlias node so that recursive aliases with varying
602603
# type arguments are still caught.
604+
assert t.alias is not None, f"Unfixed type alias {t.type_ref}"
603605
if self.seen_aliases is None:
604606
self.seen_aliases = set()
605607
elif t.alias in self.seen_aliases:

0 commit comments

Comments
 (0)