Draft PEP: Sealed decorator for static typing

I’m not sure I see the case for ADTs in python. I expressed some of this in the thread relating to Union support for __match_args__, but something I’d need to see is how this improves use at runtime, not just for typing. If it’s just for static typing, there are existing methods like:

I’d also need things to be reusable and composable. I don’t think any iteration of a sealed type does this well, including the decorators that require specifying the allowed types they wrap as forward references.

Right now, the closest things in the standard library are enums and data classes

I’m not saying it belongs in enum, but something that worked in a similar manner

class SomeADT(enum.ADT)
    A: TypeA
    B: TypeB

instb = TypeB()
b = SomeADT(instb)  # SomeADT.B
b.value # instb

seems much more likely to be able to gain wider support as it would work at runtime, wouldn’t mix sealed types with ADTs, It might also be easier to demonstrate some of the harder problems that people have with the status quo if you arent’ demonstrating it with something that makes it easy for someone to say “just use a union” by showing runtime capability with static inference possible