Skip to content

gh-161311: Document inherited abstract methods in collections.abc - #161319

Merged
picnixz merged 3 commits into
python:mainfrom
Bayel1602:patch-1
Nov 4, 2026
Merged

picnixz merged 3 commits into
python:mainfrom
Bayel1602:patch-1

Conversation

@Bayel1602

@Bayel1602 Bayel1602 commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Update the collections.abc documentation table to consistently list all required abstract methods, including inherited ones.

  • Add __iter__() to Reversible (inherited from Iterable).
  • Add __await__() to Coroutine (inherited from Awaitable).

The existing table structure remains unchanged.

Closes #161311

@Bayel1602
Bayel1602 requested a review from rhettinger as a code owner November 4, 2026 15:15
@python-cla-bot

python-cla-bot Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

Comment thread Doc/library/collections.abc.rst Resolved
@read-the-docs-community

read-the-docs-community Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #35647403 | 📁 Comparing 55b4dd7 against main (44579b0)

  🔍 Preview build  

2 files changed
± library/collections.abc.html
± whatsnew/changelog.html

@picnixz picnixz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had troubles indeed knowing what was marked as abstract and what was not, but I think this is correct here. Can you check that all classes in the table that do not have a column in abstract methods are really concrete classes that can be instantiated?

@Bayel1602

Copy link
Copy Markdown
Contributor Author

I checked the four classes with empty "Abstract Methods" cells: MappingView, ItemsView, KeysView, and ValuesView.

All four have empty __abstractmethods__ sets and can be instantiated directly with a mapping.

So the empty cells appear to be correct.

Comment thread Doc/library/collections.abc.rst Resolved
…text

Added a note about the 'Abstract Methods' column in the collections ABCs documentation.
@picnixz

picnixz commented Nov 4, 2026

Copy link
Copy Markdown
Member

For backports, can you check that all the methods you added were already abstract since 3.14? I just don't want to backport a wrong doc change

@Bayel1602

Copy link
Copy Markdown
Contributor Author

I checked the source code for the Python 3.14.0 release (Lib/_collections_abc.py).

Both methods were already abstract:

  • Reversible inherits the abstract __iter__() from Iterable.
  • Coroutine inherits the abstract __await__() from Awaitable.

Neither class provides a concrete implementation of the inherited method, so both additions are valid for the 3.14 documentation backport.

@picnixz
picnixz merged commit 1dd8e71 into python:main Nov 4, 2026
42 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Docs PRs Nov 4, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @Bayel1602 for the PR, and @picnixz for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Nov 4, 2026

Copy link
Copy Markdown

GH-161330 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Nov 4, 2026
@bedevere-app

bedevere-app Bot commented Nov 4, 2026

Copy link
Copy Markdown

GH-161331 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Nov 4, 2026
@picnixz

picnixz commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Arf, I missed a typo, but I fixed the backport. Could you.. open another PR for fixing the typo please?

The collections module offers the following :term:`ABCs <abstract base class>`:

The "Abstract Methods" column lists all required abstract methods,
including those inherited from parent classes.

should be

The collections module offers the following :term:`ABCs <abstract base class>`,
where the "Abstract Methods" column lists all required abstract methods,
including those inherited from parent classes:

(otherwise the : introduces the caption sentence)

@Bayel1602

Copy link
Copy Markdown
Contributor Author

I've opened a follow-up PR to fix the introductory text: #161333

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

Labels

docs Documentation in the Doc dir skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Inconsistent listing of inherited abstract methods in collections.abc documentation

2 participants