[issue45024] Cannot extend collections ABCs with protocol

Ken Jin report at bugs.python.org
Thu Sep 2 11:28:45 EDT 2021


Ken Jin <kenjin4096 at gmail.com> added the comment:

I suspect this may be intentional. See related issues https://bugs.python.org/issue35190 and https://bugs.python.org/issue23864.

Copying verbatim from what Ivan said in the first issue:

"
The separation may look arbitrary, but the idea is quite simple. Only those classes with few methods support structural checks. Those classes have few independent abstract methods (or even just one method), while in classes with large APIs like `Sequence`, the methods are not logically independent, so you can't say a class is 100% a `Sequence` even if types/signatures of all methods are correct, because e.g. `__contains__()` and `index()` should behave in agreement with `__getitem__()`.
"

----------

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


More information about the Python-bugs-list mailing list