Message388827
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'
``` |
|
Date |
User |
Action |
Args |
2021-03-16 10:02:24 | paul-dest | set | recipients:
+ paul-dest |
2021-03-16 10:02:24 | paul-dest | set | messageid: <1615888944.07.0.094574416265.issue43512@roundup.psfhosted.org> |
2021-03-16 10:02:24 | paul-dest | link | issue43512 messages |
2021-03-16 10:02:23 | paul-dest | create | |
|