Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.0.4 #11

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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