You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
type PosDefaultParam[T] = Param[Literal[None], T, Literal["default"]]
34
+
type DefaultParam[N: str, T] = Param[N, T, Literal["default"]]
35
+
type NamedParam[N: str, T] = Param[N, T, Literal["keyword"]]
36
+
type NamedDefaultParam[N: str, T] = Param[N, T, Literal["keyword", "default"]]
37
+
type ArgsParam[T] = Param[Literal[None], T, Literal["*"]]
38
+
type KwargsParam[T] = Param[Literal[None], T, Literal["**"]]
31
39
32
40
And then, we can represent the type of a function like::
33
41
@@ -59,6 +67,21 @@ as (we are omiting the ``Literal`` in places)::
59
67
]
60
68
61
69
70
+
or, using the type abbreviations we provide::
71
+
72
+
Callable[
73
+
[
74
+
PosParam[int],
75
+
Param["b", int],
76
+
DefaultParam["c", int,
77
+
ArgsParam[int, "*"],
78
+
NamedParam["d", int],
79
+
NamedDefaultParam["e", int],
80
+
KwargsParam[int],
81
+
],
82
+
int,
83
+
]
84
+
62
85
Rationale
63
86
'''''''''
64
87
We need extended callable support, in order to inspect and produce callables via type-level computation. mypy supports `extended callables <https://mypy.readthedocs.io/en/stable/additional_features.html#extended-callable-types>`__ but they are deprecated in favor of callback protocols.
0 commit comments