[docs] [issue32621] Problem of consistency in collection.abc documentation

Raymond Hettinger report at bugs.python.org
Fri Aug 23 02:24:41 EDT 2019


Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:

The table is correct.  See the interactive session below for confirmation.  I think the source of your confusion is that some of the more complex ABCs are able to generate some of the required methods from the ones that are listed (for example, Mapping is able to automatically create __contains__ from __getitem__, so the former is not listed as a required abstract method).


>>> Container.__abstractmethods__
frozenset({'__contains__'})
>>> Hashable.__abstractmethods__
frozenset({'__hash__'})
>>> Iterable.__abstractmethods__
frozenset({'__iter__'})
>>> Reversible.__abstractmethods__
frozenset({'__reversed__', '__iter__'})
>>> Generator.__abstractmethods__
frozenset({'send', 'throw'})
>>> Sized.__abstractmethods__
frozenset({'__len__'})
>>> Callable.__abstractmethods__
frozenset({'__call__'})
>>> Collection.__abstractmethods__
frozenset({'__iter__', '__len__', '__contains__'})
>>> Sequence.__abstractmethods__
frozenset({'__getitem__', '__len__'})
>>> MutableSequence.__abstractmethods__
frozenset({'insert', '__getitem__', '__len__', '__delitem__', '__setitem__'})
>>> ByteString.__abstractmethods__
frozenset({'__getitem__', '__len__'})
>>> Set.__abstractmethods__
frozenset({'__iter__', '__len__', '__contains__'})
>>> MutableSet.__abstractmethods__
frozenset({'add', '__len__', '__iter__', 'discard', '__contains__'})
>>> Mapping.__abstractmethods__
frozenset({'__getitem__', '__iter__', '__len__'})
>>> MutableMapping.__abstractmethods__
frozenset({'__getitem__', '__len__', '__iter__', '__delitem__', '__setitem__'})
>>> MappingView.__abstractmethods__
frozenset()
>>> ItemsView.__abstractmethods__
frozenset()
>>> KeysView.__abstractmethods__
frozenset()
>>> ValuesView.__abstractmethods__
frozenset()
>>> Awaitable.__abstractmethods__
frozenset({'__await__'})
>>> Coroutine.__abstractmethods__
frozenset({'send', 'throw', '__await__'})
>>> AsyncIterable.__abstractmethods__
frozenset({'__aiter__'})
>>> AsyncIterator.__abstractmethods__
frozenset({'__anext__'})
>>> AsyncGenerator.__abstractmethods__
frozenset({'athrow', 'asend'})

----------
resolution:  -> not a bug
stage: needs patch -> resolved
status: open -> closed

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


More information about the docs mailing list