Skip to content

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

@dphi

Description

@dphi

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions