python-cachier / cachier

Persistent, stale-free, local and cross-machine caching for Python functions.
MIT License
542 stars 60 forks source link

Bug in using cachier as a python method decorator when caching is disabled globally? #212

Closed dphi closed 2 months ago

dphi commented 5 months ago

Hi, there seems to be an issue when cachier is being used as a decorator for a method. - Or am I understanding cachier wrong?

# Python 3.12.3
import cachier  # v3.0.0

@cachier.cachier()
def test():
    return True

class Test:
    @cachier.cachier()
    def test(self):
        return True

if __name__ == "__main__":
    assert Test().test() == True  # Works
    assert test() == True         # Works
    cachier.enable_caching()
    assert Test().test() == True  # Works
    assert test() == True         # Works
    cachier.disable_caching()
    assert test() == True         # Works
    assert Test().test() == True  # TypeError: Test.test() missing 1 required positional argument: 'self'

Thanks,

Philipp

shaypal5 commented 2 months ago

The fix for this bug was released in v3.0.1.