Issue 32621: Problem of consistency in collection.abc documentation (original) (raw)

Opened after https://github.com/python/cpython/pull/5270 was closed.

Here:

https://docs.python.org/3/library/collections.abc.html

Some abstract methods are inherited from a superclass. Most of the time the name of the method is mentioned in the subclass.

For example:

Collection inherit from Sized, Iterable and Contains. But len, iter and contains are mentioned, even if they are inherited.

Mapping inherits from Collection, but len and iter appears in the table

There is one exception: Coroutine. It inherits from Awaitable but we don't see await.

What would we do? Let all appear or not?

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'})