Skip to content

Commit

Permalink
Remove args/kwargs from @_store_on_self(func) (#726)
Browse files Browse the repository at this point in the history
This brings our custom @_store_on_self(func) decorator's behavior closer
to Python's built-in @functools.cached_property(func) decorator.

https://docs.python.org/3/library/functools.html#functools.cached_property
  • Loading branch information
brainix authored Jan 11, 2024
1 parent 8fb6c92 commit 72ca2bc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pottery/bloom.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ def _store_on_self(*, attr: str) -> Callable[[F], F]:
"Decorator to store/cache a method's return value as an attribute on self."
def decorator(func: F) -> F:
@functools.wraps(func)
def wrapper(self: Any, *args: Any, **kwargs: Any) -> Any:
def wrapper(self: Any) -> Any:
try:
value = getattr(self, attr)
except AttributeError:
value = func(self, *args, **kwargs)
value = func(self)
setattr(self, attr, value)
return value
return cast(F, wrapper)
Expand Down

0 comments on commit 72ca2bc

Please sign in to comment.