
5 Feb
2022
5 Feb
'22
9:21 p.m.
Hello all,
Why can’t we use the literals directly as types? For example,
x: Literal[1, 2, 3] = 3 name: Literal[“John”] | None = “John"
Become ….
x: 1 | 2 | 3 = 3 name: “John” | None = “John"
def open(file: Path | str, mode: “w” | “a” = “w”): …
Best Regards,
Abdulla