[Python-ideas] Structural type checking for PEP 484
kramm at google.com
Thu Sep 10 20:20:38 CEST 2015
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.
Are the return types of methods invariant or variant under this proposal?
I.e. if I have
def f() -> int: ...
def f() -> bool:
implicitly implement the protocol?
Also, marking Protocols using subclassing seems confusing and error-prone.
In your examples above, one would think that you could define a new
class SizedAndClosable(Sized, Protocol):
because Sized is already a protocol.
Maybe the below would be a more intuitive syntax:
Furthermore, I strongly agree with #7. Typed, but optional, attributes are
a bad idea.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas