Skip to content

Commit 79dd493

Browse files
Adding wraps of function in Cache decorator
1 parent e468144 commit 79dd493

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

cache/cache/cache.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from datetime import datetime, timedelta
99
from typing import Callable, Any, TypeVar, Dict, Tuple, FrozenSet
10+
from functools import wraps
1011

1112
try: # use gamuLogger if available # pragma: no cover
1213
from gamuLogger import Logger
@@ -36,6 +37,7 @@ def __init__(self, /, expire_in: timedelta|None = None, expire_at: datetime|None
3637
] = {}
3738

3839
def __call__(self, func : Callable[..., T]) -> Callable[..., T]:
40+
@wraps(func)
3941
def wrapper(*args : Any, **kwargs : Any) -> T:
4042
key = (args, frozenset(kwargs.items()))
4143
if key in self.cache:
@@ -48,10 +50,6 @@ def wrapper(*args : Any, **kwargs : Any) -> T:
4850
self.cache[key] = (result, datetime.now())
4951
return result
5052

51-
wrapper.__name__ = func.__name__
52-
wrapper.__doc__ = func.__doc__
53-
wrapper.__module__ = func.__module__
54-
wrapper.__annotations__ = func.__annotations__
5553
wrapper.__dict__.update(func.__dict__)
5654
wrapper.__wrapped__ = func
5755
wrapper.__defaults__ = func.__defaults__

0 commit comments

Comments
 (0)