The pipe symbol |
is used to represent Union in versions 3.10+.
Union[str, int]
can be abbreviated as str | int
.
Additionally, Optional[T]
can be simplified to T | None
making use of union.
Of course, I realize that readability should take precedence over conciseness.
My suggestion is to introduce a syntax like T?
to abbreviate Optional[T]
. Sorry if this is not a good proposal; please let me know of the problems with it.