Skip to content

[Bug]: pyright reports type error when calling a bound method decorated with lru_cache #173

@slqy123

Description

@slqy123

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]

  • I already understand the cause and want to submit a bugfix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions