awolverp / cachebox

The fastest memoizing and caching Python library written in Rust.
https://pypi.org/project/cachebox/
MIT License
260 stars 4 forks source link

Bug with cachedmethod function #10

Closed owocado closed 2 months ago

owocado commented 2 months ago

Hello and greetings,

According to documentation, it says that cachedmethod function ignores self parameter but as I'm using it currently, it somehow requires it: image

Is this a bug in cachebox v4.1.0?

awolverp commented 2 months ago

Hi, sorry for the delay I trying to find out the problem ...

awolverp commented 2 months ago

I just noticed this problem. When we use a class as a decorator, this problem will happen.

class wrap:
    def __init__(self, func) -> None:
        self.func = func

    def __call__(self, *args, **kwds):
        return self.func(*args, **kwds)

class Test:
    @wrap
    def test(self, *args, **kwargs):
        pass

a = Test()
a.test()
# TypeError: Test.test() missing 1 required positional argument: 'self'

I will fix this problem in cachebox ASAP.

owocado commented 2 months ago

oh interesting, thank you very much for the follow up. 👍🏼

owocado commented 2 months ago

Thanks 😅 and have a great day ahead!