Skip to content

Commit 2ce612f

Browse files
authored
docs: Add through to available port directions (#122)
* Add `through` to available port directions * Introduce AnyQrefType type
1 parent b4d6bf3 commit 2ce612f

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

docs/format.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ Let us first take a look at ports, like the first input port of our program:
8686

8787
Ports, like most other components in QREF, have names, which should be distinct
8888
among all ports of any given program (or subroutine). Each port also has
89-
direction, which can be either `input` or `output`. Finally, each port has size.
89+
direction, which can be either `input`, `output` or `through` (for ports serving as
90+
both input and output). Finally, each port has size.
9091
In our simple scenario, all sizes are positive integers. However, QREF
9192
is not limited to them, and size of a port can be either:
9293

src/qref/functools.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818

1919
from .schema_v1 import RoutineV1, SchemaV1
2020

21+
AnyQrefType = dict[str, Any] | SchemaV1 | RoutineV1
22+
2123

2224
@singledispatch
23-
def ensure_routine(data: dict[str, Any] | SchemaV1 | RoutineV1) -> RoutineV1:
25+
def ensure_routine(data: AnyQrefType) -> RoutineV1:
2426
"""Ensure that given objects is of RoutineV1 type.
2527
2628
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:
5759
T = TypeVar("T")
5860

5961

60-
def accepts_all_qref_types(
61-
f: Callable[Concatenate[RoutineV1, P], T]
62-
) -> Callable[Concatenate[SchemaV1 | RoutineV1 | dict[str, Any], P], T]:
62+
def accepts_all_qref_types(f: Callable[Concatenate[RoutineV1, P], T]) -> Callable[Concatenate[AnyQrefType, P], T]:
6363
"""Make a callable accepting RoutineV1 as first arg capable of accepting arbitrary QREF object.
6464
6565
Here, by arbitrary QREF object we mean either an instance of SchemaV1, an instance of RoutineV1,

0 commit comments

Comments
 (0)