The four protocol-like ABCs outside of collections.abc inherit from ABC directly (#13005)

This commit is contained in:
Stephen Morton
2024-11-16 10:00:39 -08:00
committed by GitHub
parent 7c7629d909
commit f554f54673
3 changed files with 18 additions and 6 deletions

View File

@@ -411,8 +411,11 @@ else:
def __or__(self, right: Any) -> _SpecialForm: ...
def __ror__(self, left: Any) -> _SpecialForm: ...
# mypy and pyright object to this being both ABC and Protocol.
# At runtime it inherits from ABC and is not a Protocol, but it is on the
# allowlist for use as a Protocol.
@runtime_checkable
class Buffer(Protocol):
class Buffer(Protocol, abc.ABC): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
# Not actually a Protocol at runtime; see
# https://github.com/python/typeshed/issues/10224 for why we're defining it this way
def __buffer__(self, flags: int, /) -> memoryview: ...