Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion mypy/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -5597,7 +5597,8 @@ def visit_type_alias_stmt(self, s: TypeAliasStmt) -> None:
else:
incomplete_target = has_placeholder(res)

if self.found_incomplete_ref(tag) or incomplete_target:
incomplete_tv = any(has_placeholder(tv) for tv in alias_tvars)
if self.found_incomplete_ref(tag) or incomplete_target or incomplete_tv:
# Since we have got here, we know this must be a type alias (incomplete refs
# may appear in nested positions), therefore use becomes_typeinfo=True.
self.mark_incomplete(s.name.name, s.value, becomes_typeinfo=True)
Expand Down
9 changes: 9 additions & 0 deletions test-data/unit/check-python312.test
Original file line number Diff line number Diff line change
Expand Up @@ -2111,3 +2111,12 @@ if T(x) is str: # E: "TypeAliasType" not callable
reveal_type(x) # N: Revealed type is "builtins.object"
[builtins fixtures/tuple.pyi]
[typing fixtures/typing-full.pyi]

[case testPEP695TypeAliasForwardReferenceInUnusedTypeVar]
# https://discuss.python.org/t/103305
type Alias1[T: "A"] = int
type Alias2[T: ("A", int)] = int
class A: ...

x1: Alias1[A] # ok
x2: Alias2[A] # ok
Loading