This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author paul-dest
Recipients paul-dest
Date 2021-03-16.10:02:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1615888944.07.0.094574416265.issue43512@roundup.psfhosted.org>
In-reply-to
Content
The section "Subtyping relationships with other types" of PEP 544 states:

"A concrete type X is a subtype of protocol P if and only if X implements all protocol members of P with compatible types. In other words, subtyping with respect to a protocol is always structural."

This requirement is violated by the current implementation of CPython (version 3.9.2):

```
from typing import Protocol


class P(Protocol):
    pm: str  # no default value, but still a protocol member


class C(P):
    # inherits P but does NOT implement pm, since P did not provide a default value
    pass

    
assert isinstance(C(), P)  # violates the PEP 544 requirement cited above

C().pm  # raises: AttributeError: 'C' object has no attribute 'pm'
```
History
Date User Action Args
2021-03-16 10:02:24paul-destsetrecipients: + paul-dest
2021-03-16 10:02:24paul-destsetmessageid: <1615888944.07.0.094574416265.issue43512@roundup.psfhosted.org>
2021-03-16 10:02:24paul-destlinkissue43512 messages
2021-03-16 10:02:23paul-destcreate