PEP 695: Type Parameter Syntax

I also think that the new type alias syntax has the most potential for bike shedding. I don’t think this pattern appears anywhere in Python?

<keyword> <varname> = <value>

Maybe it could instead be modeled after import module as mod? Something like this?

alias (list[T] | set[T]) as ListOrSet[T]

EDIT:
Can also be multi-line of course:

alias (
    dict[str, Json] | list[Json] | str | int | float | bool | None
) as Json

But I also see that type is a good choice for a new (soft) keyword because it’s already the name of a built-in function. So maybe this instead

type dict[str, int] as MyDict
1 Like