From 03b4c58e67b503958fd616b39e8dc55dca7e8fb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Ja=C5=82owiecki?= Date: Sun, 29 Sep 2024 16:42:22 -0700 Subject: [PATCH] Introduce AnyQrefType type --- src/qref/functools.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/qref/functools.py b/src/qref/functools.py index 9a414cd..fcc88c1 100644 --- a/src/qref/functools.py +++ b/src/qref/functools.py @@ -18,9 +18,11 @@ from .schema_v1 import RoutineV1, SchemaV1 +AnyQrefType = dict[str, Any] | SchemaV1 | RoutineV1 + @singledispatch -def ensure_routine(data: dict[str, Any] | SchemaV1 | RoutineV1) -> RoutineV1: +def ensure_routine(data: AnyQrefType) -> RoutineV1: """Ensure that given objects is of RoutineV1 type. This functions may serve for constructing functions accepting either RoutineV1 oor SchemaV1 @@ -57,9 +59,7 @@ def _ensure_routine_from_routine_v1(data: RoutineV1) -> RoutineV1: T = TypeVar("T") -def accepts_all_qref_types( - f: Callable[Concatenate[RoutineV1, P], T] -) -> Callable[Concatenate[SchemaV1 | RoutineV1 | dict[str, Any], P], T]: +def accepts_all_qref_types(f: Callable[Concatenate[RoutineV1, P], T]) -> Callable[Concatenate[AnyQrefType, P], T]: """Make a callable accepting RoutineV1 as first arg capable of accepting arbitrary QREF object. Here, by arbitrary QREF object we mean either an instance of SchemaV1, an instance of RoutineV1,