GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Inconsistent listing of inherited abstract methods in collections.abc documentation · Issue #161311 · python/cpython

Inconsistent listing of inherited abstract methods in collections.abc documentation #161311

New issue
Copy link
New issue
Copy link
Closed
#161319
Closed
Inconsistent listing of inherited abstract methods in collections.abc documentation#161311
#161319
Copy link
Assignees
Bayel1602
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir

Description

@Bayel1602
Bayel1602
opened on Nov 4, 2026
Issue body actions

Documentation

Thanks for maintaining such comprehensive Python documentation!

While studying collections.abc, I noticed a small inconsistency in how inherited abstract methods are listed in the documentation table.

Description

The "Abstract Methods" column does not consistently indicate whether it lists only methods declared directly in an ABC or all abstract methods that subclasses must implement.

For example:

  • Reversible inherits from Iterable, so subclasses must implement both __iter__() and __reversed__(). However, the table lists only __reversed__().
  • Collection inherits from Sized, Iterable, and Container. The table lists all three inherited abstract methods: __contains__(), __iter__(), and __len__().

This makes it difficult to determine the complete set of required methods from the table alone.

Suggested improvement

I suggest distinguishing between directly declared abstract methods and all required abstract methods, including inherited ones.

For example:

ABC Inherits from Directly declared abstract methods All required abstract methods Mixin methods
Reversible Iterable __reversed__() __iter__(), __reversed__() —
Collection Sized, Iterable, Container — __contains__(), __iter__(), __len__() —

This structure clearly distinguishes abstract methods declared directly in each ABC from those inherited from parent classes, making the complete interface requirements easier to understand.

Alternatively, the existing table could simply list all required abstract methods consistently, without adding new columns.

Either approach would improve clarity and make the documentation easier to use when implementing custom classes.

This suggestion concerns documentation clarity only and does not require changes to Python's behavior.

I hope this suggestion is helpful. Thanks for your time and for considering it!

Linked PRs

  • gh-161311: Document inherited abstract methods in collections.abc #161319
  • [3.15] gh-161311: Document inherited abstract methods in collections.abc (GH-161319) #161330
  • [3.14] gh-161311: Document inherited abstract methods in collections.abc (GH-161319) #161331
  • gh-161311: fix prose in collections.abc post GH-161319 #161333

Activity

  1. Bayel1602
    added
    docsDocumentation in the Doc dirDocumentation in the Doc dir
    on Nov 4, 2026
  2. github-project-automation
    added this to docs issueson Nov 4, 2026
  3. github-project-automation
    moved this to Todo in docs issueson Nov 4, 2026
  4. picnixz commented on Nov 4, 2026

    @picnixz
    picnixz
    on Nov 4, 2026
    Member
    More actions

    I think the table would be less readable on small devices (wide tables on a laptop render poorly IMO). I'd assume that people traceback the tree for each methods they need to implement though. OTOH, showing ALL methods that need to be implemented also makes it even harder to read.

    Now, since we are anyway inconsistent, I think we can lean towards enumerating all those that need to be implemented. The other possibility is to list the methods and the classes that need them. How many methods at most a collection type needs to implement (inherited ones included)? and how many different dunders are there?

  5. Bayel1602 commented on Nov 4, 2026

    @Bayel1602
    Bayel1602
    on Nov 4, 2026
    ContributorAuthor
    More actions

    Thanks for your feedback!

    I agree that adding more columns could make the table harder to read, especially on smaller screens.

    I checked the abstract methods in Python 3.14:

    • The maximum number of required abstract methods for a single ABC is 5 (MutableSequence, MutableMapping, and MutableSet).
    • There are 21 distinct abstract method names in collections.abc, including 14 dunder methods.

    Regarding the alternative structure where methods are listed alongside the classes that require them, I think it might be less convenient for developers implementing a specific interface.

    For example, someone implementing MutableSequence would have to search through multiple rows to identify all the required methods, rather than finding everything in one place.

    For this reason, I would prefer keeping the existing table structure and consistently listing all required abstract methods, including inherited ones.

    Since the maximum is only five methods per ABC, I think this would be a reasonable compromise that improves clarity without adding more columns.

  6. Bayel1602 commented on Nov 4, 2026

    @Bayel1602
    Bayel1602
    on Nov 4, 2026
    ContributorAuthor
    More actions

    For example, a small section of the updated table could look like this:

    ABC Inherits from Required abstract methods (including inherited) Mixin methods
    Iterator Iterable __next__() __iter__()
    Reversible Iterable __iter__(), __reversed__() —
    Collection Sized, Iterable, Container __contains__(), __iter__(), __len__() —
    Sequence Reversible, Collection __getitem__(), __len__() __contains__(), __iter__(), __reversed__(), index(), count()

    This approach makes all required abstract methods explicit while preserving the original four-column layout, with only a slight increase in row height and no significant impact on table width.

  7. picnixz commented on Nov 4, 2026

    @picnixz
    picnixz
    on Nov 4, 2026
    Member
    More actions

    ok, with 5 abtract methods at most, I believe it's fine to put them all in the table.

  8. picnixz commented on Nov 4, 2026

    @picnixz
    picnixz
    on Nov 4, 2026
    Member
    More actions

    @Bayel1602 do you want to create a PR for that?

  9. Bayel1602 commented on Nov 4, 2026

    @Bayel1602
    Bayel1602
    on Nov 4, 2026
    ContributorAuthor
    More actions

    Yes, I'd be happy to! I'll prepare a PR for this

    Reacted by Bénédikt Tran
  10. picnixz
    assigned
    Bayel1602
    on Nov 4, 2026
  11. Bayel1602
    added 3 commits that reference this issue on Nov 4, 2026

    pythongh-161311: Document inherited abstract methods in collections.abc

    40f08c1

    pythongh-161311: Clarify abstract methods column header

    a833066

    pythongh-161311: Move abstract methods clarification to introductory …

    55b4dd7
  12. picnixz
    added a commit that references this issue on Nov 4, 2026

    gh-161311: Document inherited abstract methods in `collections.abc` (#…

    1dd8e71
  13. picnixz
    closed this as completedin #161319on Nov 4, 2026
  14. Bayel1602
    added a commit that references this issue on Nov 4, 2026

    pythongh-161311: Fix introductory text in collections.abc

    3bc6942
  15. StanFromIreland
    added a commit that references this issue on Nov 4, 2026

    gh-161311: Fix introductory text in `collections.abc` after GH-161319 (…

    31bd6a4
  16. picnixz
    added a commit that references this issue on Nov 6, 2026

    [3.15] gh-161311: Document inherited abstract methods in `collections…

    bb99355
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @Bayel1602
    Bayel1602

Labels

docsDocumentation in the Doc dirDocumentation in the Doc dir

Projects

  • docs issues
    Status
    Todo
    Show more project fields

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.