What happened?
Here is the error message.
/tmp/a/test.py:6:20 - error: Cannot access attribute "bar" for class "A*"
Argument of type "Self@A" cannot be assigned to parameter "instance" of type "None" in function "__get__"
"A*" is not assignable to "None" (reportAttributeAccessIssue)
This happens for pyright >= 1.1.394, tested in python = 3.12.7, 3.13.2 and asyncstdlib = 3.13.0.
But for mypy this is ok, so it may be an issue with pyright, but I do not know the exact reason behind it.
Minimal Reproducible Example
from asyncstdlib import lru_cache
class A:
async def foo(self):
await self.bar("hello") # error
await A.bar(self, "hello") # this is ok
@lru_cache
async def bar(self, x: str):
print("hello")
return x
Request Assignment [Optional]