Skip to content

Commit

Permalink
Introduce AnyQrefType type
Browse files Browse the repository at this point in the history
  • Loading branch information
dexter2206 committed Sep 29, 2024
1 parent 83991a3 commit 03b4c58
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/qref/functools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 03b4c58

Please sign in to comment.