qref.functools
Tools for constructing functions operating on Qref objects.
ensure_routine
Ensure that given objects is of RoutineV1 type.
This functions may serve for constructing functions accepting either RoutineV1 oor SchemaV1 objects, as well as dictionaries that represent them.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
AnyQrefType
|
the objects that has to be converted (if neccessary) to RoutineV1. Can either be |
required |
Returns:
Type | Description |
---|---|
RoutineV1
|
An object of type RoutineV1 corresponding to the provided data. |
Source code in src/qref/functools.py
_ensure_routine_from_dict
_ensure_routine_from_schema_v1
_ensure_routine_from_routine_v1
accepts_all_qref_types
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, or any dictionary that can be converted to an instance of SchemaV1 or RoutineV1.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
f |
Callable[Concatenate[RoutineV1, P], T]
|
Callable to be augmented. |
required |
Returns:
Type | Description |
---|---|
Callable[Concatenate[AnyQrefType, P], T]
|
A new callable preserving behavoiur of f, but also capable of accepting SchemaV1 instance or dicts |
Callable[Concatenate[AnyQrefType, P], T]
|
as first arguments. |