Skip to content

[cpython 3.9] Decorating a classmethod doesn't work #511

Open
@daviddavis

Description

It appears that alru_cache does not seem to work for classmethods. Here's a contrived example.

import asyncio

from async_lru import alru_cache


class Incrementer:
    inc = 1

    @classmethod
    @alru_cache
    async def increment(cls, num):
        return cls.inc + num


async def main():
    print(await Incrementer.increment(5))

asyncio.run(main())

Error:

TypeError: increment() missing 1 required positional argument: 'num'

I would expect it to work since lru_cache works for classmethods.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions