On Thu, May 25, 2017 at 7:19 AM, Nick Coghlan <ncoghlan@gmail.com> wrote:
Given the abstract, I'd suggest "Structural Subtyping" as a suitable title for the PEP.
Maybe even "Structural Subtyping (a.k.a. Duck Typing)"
That said, I think it's fine to use "protocol" throughout the rest of the PEP as is currently the case - object protocols and network protocols are clearly different things, it's just the bare word "Protocols" appearing as a PEP title in the PEP index with no other context that's potentially confusing.
Agreed.
I'm +1 on the general idea of the PEP, and only have one question regarding the specifics. Given:
import typing
class MyContainer: def __len__(self) -> int: ... def close(self) -> None: ...
Would that be enough for a static typechecker to consider MyContainer a structural subtype of both typing.Sized and SupportsClose from the PEP, even though neither is imported explicitly into the module? I'm assuming the answer is "Yes", but I didn't see it explicitly stated anywhere.
Yes. Imports don't enter the matter. (Things get tied together at the call sites.) @Ivan: if there isn't an example that makes this clear we should add one. -- --Guido van Rossum (python.org/~guido)