QUERY · ISSUE
Method Resolution Order (MRO) is not compliant
py-core
uPy currently implements depth-first MRO, which is equivalent to one used pre-Python2.2.
References:
- http://python-history.blogspot.com/2010/06/method-resolution-order.html
- https://www.python.org/download/releases/2.3/mro/
CANDIDATE · PULL REQUEST
py/objtype: Add type.__bases__ attribute.
py-core
Proposal: Add __bases__ attribute to types so that the inheritance heirachy can be inspected. Related to #5106 and #4368
I have not implemented .__base__ nor have I made any changes to anything MRO related. This is simply a read-only attribute that supports single and multiple inheritance.
For me, the intent of this addition is so I can type check objects in my application to ensure they inherit from a common base class.
It should be noted that I would like to add documentation and tests for this, once we finalize the draft. I'm not proposing we ignore housekeeping.
Example:
>>> class A:
... pass
>>> class B(object):
... pass
>>> class C(B):
... pass
>>> class D(C, A):
... pass
>>> A.__bases__
(<class 'object'>,)
>>> B.__bases__
(<class 'object'>,)
>>> C.__bases__
(<class 'B'>,)
>>> D.__bases__
(<class 'C'>, <class 'A'>)