<div dir="ltr">On Wednesday, September 9, 2015 at 1:19:12 PM UTC-7, Guido van Rossum wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir="ltr">Jukka wrote up a proposal for structural subtyping. It's pretty good. Please discuss.<br><br><a href="https://github.com/ambv/typehinting/issues/11#issuecomment-138133867" target="_blank" rel="nofollow" onmousedown="this.href='https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Fambv%2Ftypehinting%2Fissues%2F11%23issuecomment-138133867\46sa\75D\46sntz\0751\46usg\75AFQjCNGkLDRhZzgQ26XG6xvrfB7qY7HlIw';return true;" onclick="this.href='https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Fambv%2Ftypehinting%2Fissues%2F11%23issuecomment-138133867\46sa\75D\46sntz\0751\46usg\75AFQjCNGkLDRhZzgQ26XG6xvrfB7qY7HlIw';return true;">https://github.com/ambv/<wbr>typehinting/issues/11#<wbr>issuecomment-138133867</a></div></blockquote><div><br></div><div>I like this proposal; given Python's flat nominal type hierarchy, it will be useful to have a parallel subtyping mechanism to give things finer granularity without having to resort to ABCs.</div><div><br></div><div>Are the return types of methods invariant or variant under this proposal?</div><div><br></div><div>I.e. if I have</div><div><br></div><div>  class A(Protocol):</div><div>  Â  def f() -> int: ...</div><div><br></div><div>does</div><div><br></div><div>  class B:</div><div>  Â  def f() -> bool:</div><div>  Â  Â  return True</div><div><br></div><div>implicitly implement the protocol A?</div><div><br></div><div>Also, marking Protocols using subclassing seems confusing and error-prone.</div><div>In your examples above, one would think that you could define a new protocol using</div><div><br></div><div>class SizedAndClosable(Sized):</div><div>  Â  pass</div><div><br></div><div>instead of</div><div><br></div><div>class SizedAndClosable(Sized, Protocol):</div><div>  Â  pass</div><div><br></div><div>because Sized is already a protocol.</div><div><br></div><div>Maybe the below would be a more intuitive syntax:</div><div><br></div><div>  @protocol</div><div>  class SizedAndClosable(Sized):</div><div>  Â  Â  pass</div><div><br></div><div>Furthermore, I strongly agree with #7. Typed, but optional, attributes are a bad idea.</div><div><br></div><blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir="ltr"><div>
</div></div>
</blockquote></div>