Is your feature request related to a problem? Please describe.
Several typing features need separate declaration and type hints. This includes the planned TypeVar, Protocol (as Callable replacement) but also the potential NewType and type aliases.
The current unparse and IR has no concept for required declarations. Thus, stenotype cannot declare them automatically.
Describe the solution you'd like
Introduce declared types to the IR, which represent both the type hint and declaration. For example, a TypeVar `T would be the hint T plus the declaration T = TypeVar("T").
The unparse (and perhaps normalize) function(s) should be aware of declared types. String representations should be available both with and without declarations.
# steno
foo: '(a: A, b: B) -> R'
# typing normalized, unparsed
class a_A_b_B_to_R(Protocol):
def __call__(self, a: A, b: B) -> R: ...
foo: a_A_b_B_to_R
Describe alternatives you've considered
This is most critical for call signatures. The Protocol has more capabilities than Callable. Callable is only suitable for declaring positional and return types. Variadic or named arguments require Protocol.
Generics could require manual declarations of TypeVars.
There hasn't been any proposal for adding structural types, new types or type aliases to stenotypes. Any requirement for them are pure speculation at the moment.
Is your feature request related to a problem? Please describe. Several
typing
features need separate declaration and type hints. This includes the plannedTypeVar
,Protocol
(asCallable
replacement) but also the potentialNewType
and type aliases.The current
unparse
and IR has no concept for required declarations. Thus,stenotype
cannot declare them automatically.Describe the solution you'd like Introduce declared types to the IR, which represent both the type hint and declaration. For example, a TypeVar
`T
would be the hintT
plus the declarationT = TypeVar("T")
.The
unparse
(and perhapsnormalize
) function(s) should be aware of declared types. String representations should be available both with and without declarations.Describe alternatives you've considered This is most critical for call signatures. The
Protocol
has more capabilities thanCallable
.Callable
is only suitable for declaring positional and return types. Variadic or named arguments requireProtocol
.Generics could require manual declarations of TypeVars.
There hasn't been any proposal for adding structural types, new types or type aliases to stenotypes. Any requirement for them are pure speculation at the moment.