[Python-ideas] Improve the error message for impossible multiple inheritance
Neil Girdhar
mistersheik at gmail.com
Thu Sep 1 13:36:53 EDT 2016
I sometimes get the error message:
TypeError: Cannot create a consistent method resolution
order (MRO) for bases …
I suggest that Python report
* cycles (if there are any), or
* a list of orderings of direct base classes (if there are no cycles).
A cycle for the base classes A, B, C, D can be reported as follows:
TypeError: Cannot create a consistent method resolution
order (MRO) because A inherits from B (through X, Y), but B inherits from A
(through Z).
The topological sort could be reported as follows for base classes A, B, C,
D:
TypeError: Cannot create a consistent method resolution
order (MRO) because B inherit from C (through X, Y), but B follows C in
inheritance order.
It might be nice to have an exposed tool somewhere in the standard library
that spits out for A, B, C, D:
A, B inherit from C (through X, Y)
C inherit from D (through Z)
Best,
Neil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160901/782fceee/attachment.html>
More information about the Python-ideas
mailing list