diff --git a/src/async_utils/_typings.py b/src/async_utils/_typings.py index 41bd17a..a9b0ab5 100644 --- a/src/async_utils/_typings.py +++ b/src/async_utils/_typings.py @@ -30,16 +30,16 @@ if TYPE_CHECKING: from typing import Any, Literal, Never, Self +else: + def __getattr__(name: str): + if name in {"Any", "Literal", "Never", "Self"}: + import typing -def __getattr__(name: str): - if name in {"Any", "Literal", "Never", "Self"}: - import typing + return getattr(typing, name) - return getattr(typing, name) - - msg = f"module {__name__!r} has no attribute {name!r}" - raise AttributeError(msg) + msg = f"module {__name__!r} has no attribute {name!r}" + raise AttributeError(msg) __all__ = ["Any", "Literal", "Never", "Self"] diff --git a/src/async_utils/corofunc_cache.py b/src/async_utils/corofunc_cache.py index 62aeaa8..3eadc52 100644 --- a/src/async_utils/corofunc_cache.py +++ b/src/async_utils/corofunc_cache.py @@ -28,8 +28,8 @@ type CoroFunc[**P, R] = Callable[P, Coroutine[t.Any, t.Any, R]] type CoroLike[**P, R] = Callable[P, Awaitable[R]] -type _CT_RET = tuple[tuple[t.Any, ...], dict[t.str, t.Any]] -type CacheTransformer = Callable[[tuple[t.Any, ...], dict[t.str, t.Any]], _CT_RET] +type _CT_RET = tuple[tuple[t.Any, ...], dict[str, t.Any]] +type CacheTransformer = Callable[[tuple[t.Any, ...], dict[str, t.Any]], _CT_RET] type Deco[**P, R] = Callable[[CoroLike[P, R]], CoroFunc[P, R]] diff --git a/src/async_utils/task_cache.py b/src/async_utils/task_cache.py index 234be3a..1011ec3 100644 --- a/src/async_utils/task_cache.py +++ b/src/async_utils/task_cache.py @@ -31,8 +31,8 @@ type TaskFunc[**P, R] = CoroFunc[P, R] | Callable[P, asyncio.Task[R]] type TaskCoroFunc[**P, R] = CoroFunc[P, R] | TaskFunc[P, R] -type _CT_RET = tuple[tuple[t.Any, ...], dict[t.str, t.Any]] -type CacheTransformer = Callable[[tuple[t.Any, ...], dict[t.str, t.Any]], _CT_RET] +type _CT_RET = tuple[tuple[t.Any, ...], dict[str, t.Any]] +type CacheTransformer = Callable[[tuple[t.Any, ...], dict[str, t.Any]], _CT_RET] type Deco[**P, R] = Callable[[TaskCoroFunc[P, R]], TaskFunc[P, R]]