Skip to content

Commit

Permalink
Merge pull request #11 from 2018-11-27/master
Browse files Browse the repository at this point in the history
2.0.4
  • Loading branch information
2018-11-27 authored Oct 10, 2024
2 parents dcc078b + 66e555c commit e579c85
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion funccache/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
────────────────────────────────────────────────────────────────────────────────
Copyright (c) 2022-2024 GQYLPY <http://gqylpy.com>. All rights reserved.
@version: 2.0.3
@version: 2.0.4
@author: 竹永康 <gqylpy@outlook.com>
@source: https://github.com/gqylpy/funccache
Expand Down
7 changes: 4 additions & 3 deletions funccache/i funccache.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
TypeAlias = TypeVar("TypeAlias")

MethodTypeOrName: TypeAlias = TypeVar('MethodTypeOrName', MethodType, str)
TTL: TypeAlias = TypeVar('TTL', int, float, str)
Wrapped = WrappedClosure = TypeVar('Wrapped', bound=Callable[..., Any])
WrappedReturn: TypeAlias = TypeVar('WrappedReturn')

Expand All @@ -50,7 +51,7 @@
class FuncCache(type):
__shared_instance_cache__: bool = False
__not_cache__: List[MethodTypeOrName] = []
__ttl__: Union[str, int, float] = float('inf')
__ttl__: TTL = float('inf')

def __new__(
mcs, __name__: Union[str, Wrapped, Type[object]], *a, **kw
Expand All @@ -67,7 +68,7 @@ def __init__(cls, __name__: str, __bases__: tuple, __dict__: dict):
cls.check_and_tidy_not_cache(__not_cache__)
cls.dedup(__not_cache__)

if '__getattribute__' not in __dict__:
if '__getattribute__' in __dict__:
raise AttributeError(
f'instances of "{FuncCache.__name__}" are not allowed to '
'define method "__getattribute__".'
Expand Down Expand Up @@ -316,7 +317,7 @@ async def acore(self, *a, **kw) -> WrappedReturn:

class FunctionCallerTTL:

def __init__(self, ttl: Union[int, float, str] = float('inf'), /):
def __init__(self, ttl: TTL = float('inf'), /):
if isinstance(ttl, str):
ttl = time2second(ttl)
elif not isinstance(ttl, (int, float)):
Expand Down

0 comments on commit e579c85

Please sign in to comment.