When passing generic class (not instance) to decorator expecting callable, generic type is inferred as 'Unknown' in return type of decorated function. #6139
Labels
addressed in next version
Issue is fixed and will appear in next published version
bug
Something isn't working
Describe the bug
When passing a generic class to a decorator function which expects a callable, the generic type is inferred as 'Unknown' in the return type of the decorated function.
Code or Screenshots
In the above snipit, the class
Example
, the functionexample2
, and instances ofExample3()
all implement the same signature of__call__
, as shown by the fact that they all match theExampleCallable
Protocol
.However, when the class
Example
is passed throughdecorator
, the return type of the decorated function is inferred asExample[Unknown]
rather thanExample[T]
.When
example2
, andExample3()
are passed throughdecorator
, the return type is correctly inferred asExample[T]
.VS Code extension or command-line
I am running pyright through the pylance extension in vscode. Pylance version 2023.10.23 and Pyright version 1.1.331.
The text was updated successfully, but these errors were encountered: