El sáb, 16 abr 2022 a las 13:47, John Hagen (<johnthagen@gmail.com>) escribió:
> Yes, this would need to be a new PEP. I'd probably be willing to sponsor
> such a PEP.

Thanks Jelle. I will try to put a PEP together, likely pulling heavily from the section already written in PEP 622.

Looking at that section again, I noticed a problem with the spec at https://peps.python.org/pep-0622/#sealed-classes-as-algebraic-data-types. Given a class hierarchy with `Node` as the base class and a number of leaf classes, it says "With such definition, a type checker can safely treat Node as Union[Name, Operation, Assignment, Print]". But there is nothing in the code sample that tells a type checker that an object of type `Node` can't be an instance of the base class. Presumably you could use `abc.ABCMeta` to indicate that the base class is abstract, but that may be disruptive at runtime, because it requires using a metaclass.

Eric's feedback is also important to consider. What compelling benefit does this new type system feature provide over just using a Union?
 
_______________________________________________
Typing-sig mailing list -- typing-sig@python.org
To unsubscribe send an email to typing-sig-leave@python.org
https://mail.python.org/mailman3/lists/typing-sig.python.org/
Member address: jelle.zijlstra@gmail.com