-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Class Generic ParamSpec cannot be used in Callable #12011
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
affects-typeshed
Anything that blocks a typeshed change
bug
mypy got something wrong
topic-paramspec
PEP 612, ParamSpec, Concatenate
Comments
A colleague made a good even more minimal use-case which seems to be the actual root cause: import typing as t
P = t.ParamSpec("P")
R = t.TypeVar("R")
class Callable(t.Generic[P, R]):
pass
class Y(
t.Generic[P],
Callable[P, t.Any], # error: ParamSpec "P" is unbound
):
pass Quickly debugging Mypy shows the Line 744 in 0a03ba0
|
Reproduced on mypy 0.950 (and on mypy master as of 27/04/2022): from typing import Generic, ParamSpec
P = ParamSpec("P")
class Foo(Generic[P]): ...
class Bar(Foo[P]): ... # error: ParamSpec "P" is unbound |
8 tasks
This seems fixed as of mypy 1.0 |
Thanks :-) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
affects-typeshed
Anything that blocks a typeshed change
bug
mypy got something wrong
topic-paramspec
PEP 612, ParamSpec, Concatenate
Bug Report
Mypy doesn't seem to support a Generic class with a ParamSpec argument to use this ParamSpec in an inherited generic class.
eg:
To Reproduce
https://mypy-play.net/?mypy=master&python=3.10&gist=9edf71a609a6a1fe5764db342beaa710
This code seems to work on Pyright
Expected Behavior
The code above should pass.
Actual Behavior
The code above have an error:
error: The first argument to Callable must be a list of types or "..."
. This error seems to be from some codepath unaware of ParamSpec.Your Environment
The text was updated successfully, but these errors were encountered: