You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This may require implementing a __mro_entries__ method in objc.formal_protocol.
Disadvantage is that makes the interface for complex by having two different ways to denote that a class implements a protocol. That said, this may by helpful with static typing (especially when the representation of protocols in type stubs is some kind of type). See also #419
The text was updated successfully, but these errors were encountered:
The code for handling protocols in the parent classes is present in class_new() in objc-class.m, however I get an exception when trying to use this functionality:
TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
Implementing __mro_entries__ to ignore formal (and informal) protocols somewhat helps with this, in that the exception goes away, but also requires more work because the protocols are no longer present in the bases passed to class_new (haven't check yet if they do end up in the class dict)
The PEP introducing __mro_entries__ mentions that this method is not meant to be used outside of the typing module:
NOTE: These two method names are reserved for use by the typing module and the generic types machinery, and any other use is discouraged. The reference implementation (with tests) can be found in [4], and the proposal was originally posted and discussed on the typing tracker, see [5].
Appearently it is (once again?) possible to inherit from a non-class. That could make it more convenient to implement a protocol:
Currently:
Possible change:
This may require implementing a
__mro_entries__
method inobjc.formal_protocol
.Disadvantage is that makes the interface for complex by having two different ways to denote that a class implements a protocol. That said, this may by helpful with static typing (especially when the representation of protocols in type stubs is some kind of type). See also #419
The text was updated successfully, but these errors were encountered: