<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Mon, Nov 20, 2017 at 9:41 PM Nick Coghlan <<a href="mailto:ncoghlan@gmail.com">ncoghlan@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 21 November 2017 at 12:34, Nick Coghlan <<a href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a>> wrote:<br>
> Right, but once you do that, then the existing resolver is already<br>
> able to handle things:<br>
><br>
> >>> class C: pass<br>
> ...<br>
> >>> class S(C): pass<br>
> ...<br>
> >>> class E: pass<br>
> ...<br>
> >>> class B(S, E, C): pass<br>
> ...<br>
> >>> class R(E, C): pass<br>
> ...<br>
> >>> class Z(B, R): pass<br>
> ...<br>
> >>><br>
><br>
> If you wanted to pick up cases where two classes generate inconsistent<br>
> MROs that will prevent mutual subclasses (like "class B(S, E)" vs<br>
> "class R(E, C)"), that feels like a job for a type checker, since it<br>
> isn't obvious whether it's the definition of B or the definition of R<br>
> that should be changed to reorder their MRO.<br>
<br>
I do wonder if we might be able to make the error message here less<br>
cryptic by mentioning which *listed* base classes brought in the<br>
conflicting MRO entries.<br>
<br>
Consider the current:<br>
<br>
>>> class Z(B, R): pass<br>
...<br>
Traceback (most recent call last):<br>
File "<stdin>", line 1, in <module><br>
TypeError: Cannot create a consistent method resolution order<br>
(MRO) for bases C, E<br>
<br>
vs something like:<br>
<br>
TypeError: Cannot create a consistent method resolution order<br>
(MRO) for bases C, E (inherited through B, R)<br>
<br>
(Note: I haven't actually checked how practical it would be to<br>
implement something like that)<br></blockquote><div><br></div><div>I totally agree. I actually proposed this on ideas a few months ago and then wrote something here: <a href="https://github.com/NeilGirdhar/inheritance_graph">https://github.com/NeilGirdhar/inheritance_graph</a></div><div><br></div><div>If you have any suggestions or improvements, please feel free to improve the code.</div><div><br></div><div>Best,</div><div><br></div><div>Neil </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Cheers,<br>
Nick.<br>
<br>
--<br>
Nick Coghlan | <a href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a> | Brisbane, Australia<br>
</blockquote></div></div>