-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Incorrect handling of Concatenate when used with generics and decorators #9742
Comments
Thanks for the bug report. On first inspection, there are actually two bugs here. The first bug is a type evaluation bug that results in the |
Sorry for the poor example; I'll take your word that they should both be errors. I don't know enough type theory to have an opinion on whether But the duplicated int parameter is definitely a problem. |
…function with a callable parameter that uses Concatenate plus ParamSpec to a function that accepts a callable with just a ParamSpec. This addresses #9742.
This is addressed in pyright 1.1.393. |
Describe the bug
A clear and concise description of the behavior you are seeing and the expected behavior along with steps to reproduce it.
In the following example, we define a generic decorator that turns a (higher order) function into a MyGeneric (which could be, i.e. a descriptor).
We use that decorator on dumb_thingy, a function that takes a function and injects an
int
argument into it. The type checker should therefore assume that the ParamSpec**Args
has a single mandatoryint
argument. However, pyright incorrectly infers that there are TWO mandatory int arguments.Interestingly, this bug does NOT apply to the Callable generic, only user-defined generics. I.e. replacing
MyGeneric[Args]
withCallable[Args, Any]
exhibits the correct behavior. It also does NOT apply unless Concatenate is used. I.e. replacingConcatenate[int, P]
with[int]
exhibits the correct behavior.Tested on pyright command line version 1.1.392
Also occurs on latest pylance VSCode extension.
mypy has the correct behavior.
The text was updated successfully, but these errors were encountered: