3 ms·
I wish there was a union operator for typing as well to replace `Union[str, int]` with just `[str|int]`.
by Rotareti 7y ago
I wish there was a union operator for typing as well to replace `Union[str, int]` with just `[str|int]`.
- ash 7y agoDid you mean `str | int`?
- LyndsySimon 7y agoNaively, couldn’t your just overload `or` to make that work?
- ash 7y agoPEP 604 (draft) proposes this: def f(list: List[int | str], param: int | None) -> float | str: pass f([1, "abc"], None) https://www.python.org/dev/peps/pep-0604/ https://www.python.org/dev/peps/pep-0604/