[New-bugs-announce] [issue45024] Cannot extend collections ABCs with protocol

Anup Parikh report at bugs.python.org
Thu Aug 26 21:29:49 EDT 2021


New submission from Anup Parikh <anuppari at gmail.com>:

Since the container ABCs are normal classes, and Protocol cannot subclass normal classes, there's no way to create a protocol that extends the ABCs without explicitly listing out all the methods needed for the collection. e.g., can't do this:

from typing import Iterable, Protocol

class IterableWithMethod(Iterable, Protocol):
    def method(self) -> None: pass

Since the ABCs don't provide any default implementations (I think?), maybe they should just be defined as runtime checkable protocols instead of ABCs?

----------
components: Library (Lib), Parser
messages: 400387
nosy: anuppari, lys.nikolaou, pablogsal
priority: normal
severity: normal
status: open
title: Cannot extend collections ABCs with protocol
type: behavior

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45024>
_______________________________________


More information about the New-bugs-announce mailing list