-
Notifications
You must be signed in to change notification settings - Fork 21
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
pyright: Failed to call method "__get__" for descriptor class "LRUAsyncCallable..." #124
Comments
Thanks for the report! I can confirm that I can reproduce this issue, but I still have to figure out what exactly PyRight is complaining about here. |
This is going to take a bit longer. I've made some progress on understand I might have to build an MRE and ask the PyRight maintainers just what the thing complains about. If anyone has capacities to handle this earlier than me, feel free to move ahead. |
I seem to have tracked this down to an issue with capturing the My current MRE for the descriptor: AC = TypeVar("AC", bound=Callable[..., Awaitable[Any]])
R = TypeVar("R")
P = ParamSpec("P")
S = TypeVar("S")
class ADescr(Generic[AC]):
__call__: AC
def __init__(self, callable: AC): ...
@overload
def __get__(
self: ADescr[AC], instance: None, owner: type | None = ...
) -> ADescr[AC]: ...
@overload
def __get__(
self: ADescr[Callable[Concatenate[S, P], Awaitable[R]]],
instance: S,
owner: type | None = ...,
) -> Callable[P, Awaitable[R]]: ...
def __get__(self, instance: object | None, owner: type | None = None) -> Any: ... Which fails for a simple testcase: class Test:
@ADescr
async def foo(self, a: int) -> int:
return a
async def access(self):
return await self.foo(12)
# Cannot access member "foo" for type "Test*"
# Failed to call method "__get__" for descriptor class "ADescr[(self: Self@Test, a: int) -> Coroutine[Any, Any, int]]" Pylance[reportAttributeAccessIssue] Notably, MyPy accepts this and infers everything correctly. |
I've just reported this as microsoft/pyright#7533. |
* add missing get case * special case to workaround #124
The solution suggested in the PyRight issue doesn't work for the practical case ( |
The following code can run, but pyright will report errors.
These errors are annoying, it would be great if they could be eliminated.
Thanks for this great library!
The text was updated successfully, but these errors were encountered: