Skip to content

alru_cache decorator on a class method causes mypy error: Missing positional argument "self" #104

Closed
@atusy

Description

@atusy

Thank you for the amazing project.

I'm trying to apply alru_cache on a class method, but mypy raises an error and a note:

error: Missing positional argument "self" in call to "f" of "X"  [call-arg]
note: "__call__" is considered instance variable, to make it class variable use ClassVar[...]

below is the reproducible example tested with mypy 1.1.1 and asyncstdlib 3.10.5

from asyncstdlib.functools import lru_cache as alru_cache

class X:
    @alru_cache()
    async def f(self) -> int:
        return 1

    async def g(self) -> int:
        return await self.f()

Metadata

Metadata

Assignees

No one assigned

    Labels

    typing bugSome type hints aren't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions