New submission from Paul <paul.d...@web.de>:
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' ``` ---------- components: Library (Lib) messages: 388827 nosy: paul-dest priority: normal severity: normal status: open title: Bug in isinstance(instance, cls) with cls being a protocol? (PEP 544) type: behavior versions: Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue43512> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com