Something which appears to be missing from the design, whether intentionally so or not, is the ability to switch on type forms or to express in the type system whether a function handles specific type forms, but not others, or handles some in a different manner from others.
Copying this over from the original github issue, there was a suggestion to be able to encode this information into the type system’s handling of TypeForm by having the first argument to TypeForm be the form, and the remainder the inner annotations
@overload
def try_parse_as_value(typ: TypeForm[Annotated, T, *Annotations], user_input: str) -> T:
...
@overload
def try_parse_as_value(typ: TypeForm[Union, *Ts], user_input: str) -> Union[*Ts]:
...
@overload
def try_parse_as_value(typ: type[T], user_input: str) -> T:
...
There’s not always going to be an equivalent way to do this with
TypeForm[Form[...]] as best I can tell (due to restrictions on where parameterized generics are allowed)