GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||
GeezerVison is showing github.com — Cannot use multiple inheritance with `collections.abc.Buffer` and `typing.Protocol` · Issue #104797 · python/cpython Closed Closed Copy link Labels 3.12only security fixesonly security fixes3.13only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error DescriptionVarious stdlib classes are treated as protocols by type checkers, but are actually ABCs at runtime (for performance reasons). Examples include >>> from contextlib import AbstractContextManager >>> from typing import Protocol >>> class Foo(AbstractContextManager, Protocol): ... def extra_method(self) -> None: ... ... >>>
>>> class Bar(Buffer, Protocol): ... def extra_method(self) -> None: ... ... Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Users\alexw\coding\cpython\Lib\abc.py", line 106, in __new__ cls = super().__new__(mcls, name, bases, namespace, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\alexw\coding\cpython\Lib\typing.py", line 1916, in __init_subclass__ raise TypeError('Protocols can only inherit from other' TypeError: Protocols can only inherit from other protocols, got <class 'collections.abc.Buffer'> I think Lines 1740 to 1746 in ddb1485
Cc. @JelleZijlstra for PEP-688 Linked PRsActivity
MetadataMetadataAssigneesLabels3.12only security fixesonly security fixes3.13only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error ProjectsMilestoneRelationshipsDevelopmentIssue actions | ||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |