Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Be able to clear the process_cache manually in Python 3.11
Given code like the following ``` class Foo: @process_cached def bar(self): pass ``` In Python 3.8 referencing `bar` would not call its `__get__` method. ``` x = Foo().bar ``` However in Python 3.11, making the same call would call the `__get__` method, permanently replacing the underlying `process_cached` object with the partial function that references it. This meant that code to clear the cache would work in Python 3.8 but would break in 3.11 ``` Foo().bar.cache.clear() # Works in 3.8 but not in 3.11 ``` In 3.11 this results in the following error: ``` E AttributeError: 'functools.partial' object has no attribute 'cache' ``` To make this compatible in both version, we just add the cache as an accessible attribute on the partial we generate for our wrapped function.
- Loading branch information