Skip to content
Open
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
1 change: 1 addition & 0 deletions mypy/typeanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2523,6 +2523,7 @@ def visit_type_alias_type(self, t: TypeAliasType) -> Type:
for arg in t.args:
if not (
isinstance(arg, TypeVarLikeType)
and not (isinstance(arg, ParamSpecType) and arg.prefix.arg_types)
or isinstance(arg, UnpackType)
and isinstance(arg.type, TypeVarLikeType)
) and has_type_vars(arg):
Expand Down
13 changes: 13 additions & 0 deletions test-data/unit/check-python312.test
Original file line number Diff line number Diff line change
Expand Up @@ -2373,3 +2373,16 @@ if TYPE_CHECKING:
class Group(TypedDict):
params: "Tuple[Alias, ...]"
[builtins fixtures/tuple.pyi]

[case testPEP695TypeAliasRecursiveConcatenateNoCrash]
from typing import Callable
from typing_extensions import Concatenate

type A[**P] = Callable[[Callable[P, None]], A[Concatenate[int, P]]] # E: Invalid recursive alias: type variable nesting on right hand side
type B[**P] = Callable[[Callable[P, None]], B[P]]

def foo[**P](a: A[P], b: B[P]) -> None:
reveal_type(a) # N: Revealed type is "Any"
reveal_type(b) # N: Revealed type is "def (def (*P.args, **P.kwargs)) -> ..."
[builtins fixtures/tuple.pyi]
[typing fixtures/typing-full.pyi]
Loading