Open Avasam opened 9 months ago
As for the real world scenario where I encountered this: https://github.com/python/typeshed/pull/11336/files#diff-88b4b1d81d8a23e6e0f612acfb230bb8551893c0a56fed353784b2e744930430R48-R59
As I mentioned in the pyright issue tracker, I don't think this is a valid use of the @overload
decorator. I therefore rejected this as a bug. If we want to allow @overload
to be used on callable objects — especially when those objects have overloaded signatures for __call__
, then I think we'd need to extend the typing spec to accommodate this use case. As the typing spec is currently written, I wouldn't expect this to work.
Bug Report overloaded class-decorator is seen as not Callable when used on an overloaded method
(A clear and concise description of what the bug is.)
To Reproduce
Expected Behavior
In the short term: Maybe a better error message? It is not true that
DecoratorClass
is not callable here. In the long term: overload-expansion ? Is that even feasible?Actual Behavior
Your Environment
--platform win32 --python-version 3.8
mypy.ini
(and other config files): From typeshedAdditional information For comparison, pyright currently accepts the above and sees the type as such: (only the last method overload is kept, with the class overload)
The Pylance language server shows the following overloads