
On Fri, Nov 23, 2018 at 04:30:39PM +0000, Ivan Levkivskyi wrote:
Of course, I would prefer to keep using Enums. That would require the type checker to consider `Status` similarly to `Literal[Status.Started, Status.Finished]`.
Yes, I think an enum should be equivalent to union of all its values. IIRC this is already required by PEP 484, but was never implemented. We cab re-emphasize it in this PEP.
Thanks for pointing that out. I hadn't noticed that this appears in PEP484. The section "Support for singleton types in unions"[0] discusses this issue and has a similar example at the end. I think treating an Enum as (approximately) a union of singleton types is a good way to make that example work. [0] https://www.python.org/dev/peps/pep-0484/#support-for-singleton-types-in-uni... Ran