In the first example Union is the return type. As Literal["all", 1] is union of Literal[all] and Literal[1]. But the warning about types still persists.
My point is that with overloading and Literals/types you can precisely specify return types of functions. Something that Unions cannot do.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Why not use an Union for the return type
In the first example Union is the return type. As Literal["all", 1] is union of Literal[all] and Literal[1]. But the warning about types still persists.
My point is that with overloading and Literals/types you can precisely specify return types of functions. Something that Unions cannot do.