-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrongtopic-paramspecPEP 612, ParamSpec, ConcatenatePEP 612, ParamSpec, Concatenate
Description
Bug Report
ParamSpecs are allowed to be defined in class generics like this: Foo[[int, str]]
. This is allowed to be simplified for readability reasons like this: Foo[int, str]
. It should however only work if a ParamSpec
is the only generic type variable. In the example below however we get a weird case where this simplification is applied even though it shouldn't.
To Reproduce
from typing import Generic, TypeVar, ParamSpec
P = ParamSpec("P")
T = TypeVar("T")
class D(Generic[P, T]): ...
# Fails:
D[int, bytes, str]
# Works
D[int, bytes]
See also: https://mypy-play.net/?mypy=latest&python=3.12&gist=1c1e42d6e323cb2dcc54a7c06b440cac
Expected Behavior
In case multiple type variables or param specs are defining a class, the param spec should not be simplified and the type application above D[int, bytes]
should not be allowed.
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-paramspecPEP 612, ParamSpec, ConcatenatePEP 612, ParamSpec, Concatenate