[Python-Dev] PEP 544 and dunder methods
[originally I sent this to typing-sig but I guess it got caught up in
In PEP 554  it says:
- Implement metaclass functionality to detect whether a class is a
protocol or not. Add a class attribute _is_protocol = True if that is
the case. Verify that a protocol class only has protocol base classes in
the MRO (except for object).
The phrase "except for object" implies that having "type" in the MRO would
not be allowed. Was that intentional?
Perhaps I've misunderstood semantics with typing stuff (I haven't followed
much of the discussion), but there seems to be a disconnect with how
special ("dunder") methods are looked up (i.e. on classes). Effectively,
an object's *class* has to implement the relevant "protocol". So
disallowing "type" in the MRO means not using the PEP's functionality for
"special method" protocols (as well as metaclasses in general). Have I
understood that right? Is that on purpose?
Thanks for working on this, BTW. It's a nice addition. :)
-------------- next part --------------
An HTML attachment was scrubbed...