Skip to content

gh-160386: Apply changes from importlib_metadata 10.0 and document the shared protocols - #160344

Open
jaraco wants to merge 8 commits into
python:mainfrom
jaraco:docs/gh-123976-backport-caveats
Open

jaraco wants to merge 8 commits into
python:mainfrom
jaraco:docs/gh-123976-backport-caveats

Conversation

@jaraco

@jaraco jaraco commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Applies importlib_metadata 10.0 and documents the protocols it adds.

Sync

Lib/importlib/metadata/ picks up importlib_metadata 10.0
(python/importlib_metadata#505, for python/importlib_metadata#486):
IDistribution and IPackagePath protocols in _meta.py, both
@runtime_checkable, exported from importlib.metadata. The compat and
_compat packages, which hold localize and the warning it raises for a
provider's incomplete Distribution subclass, are excluded from the port as
usual, so only the protocols arrive here.

Documentation (gh-123976)

  • Documents IDistribution and IPackagePath.
  • Corrects the PackageMetadata entry, which described itself as "a concrete
    implementation of the PackageMetadata protocol" and linked to the backport's
    docs for the protocol. importlib.metadata._meta.PackageMetadata is itself a
    Protocol, and is exported in __all__.
  • Links to the backport's new
    Caveats
    page from the overview's seealso, from IDistribution, and from the custom
    provider example.

The caveats themselves — the two class hierarchies, what the backport
substitutes and what it passes through unchanged, and what that asks of
consumers and of custom providers — now live in the backport's documentation
(python/importlib_metadata@be2ea93bc), the concern being largely the backport's
rather than the stdlib's.

🤖 Generated with Claude Code

Describe how the separate class hierarchies in importlib.metadata and
the importlib_metadata backport affect custom providers: which objects
the backport substitutes, which it passes through with a warning, and
why a provider should implement the whole interface and rely on the
shared protocols rather than on a particular base class.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@read-the-docs-community

read-the-docs-community Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #35711378 | 📁 Comparing f234adb against main (e7e0b35)

  🔍 Preview build  

160 files changed · ± 160 modified

± Modified

importlib_metadata now decides the warning by conformance to
IDistribution rather than by class identity, so a provider that
presents the whole interface draws no warning and the warning names
what a class omits.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Comment thread Doc/library/importlib.metadata.rst Resolved
Comment thread Doc/library/importlib.metadata.rst Resolved
jaraco and others added 2 commits October 22, 2026 14:51
The guidance to rely on the interface rather than the type addresses
every consumer, not only a provider that consumes metadata, so promote
the caveats to their own section and split it by audience. Note that
the protocols come from the backport, which this module does not yet
present.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Assume the shared protocols from python/importlib_metadata#505 are
presented by this module as well: document IDistribution and
IPackagePath, correct PackageMetadata, which is already a protocol here
rather than an implementation of the backport's, and write the caveats
around the protocols as the interface both libraries satisfy.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@jaraco jaraco changed the title gh-123976: Document backport caveats for custom providers gh-123976: Document the protocols shared with the importlib_metadata backport Oct 22, 2026
jaraco and others added 2 commits October 31, 2026 15:49
Adds the IDistribution and IPackagePath protocols, so a consumer can
target one interface across this module and the backport rather than
either library's concrete classes, and annotates the functions returning
distributions and files with them.

The backport's compat and _compat packages are excluded from the port as
usual, so localize and the conformance warning it raises do not appear
here; only the protocols they are defined against do. This is what the
caveats documented for pythongh-123976 in this branch describe.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@jaraco jaraco changed the title gh-123976: Document the protocols shared with the importlib_metadata backport gh-160386: Apply changes from importlib_metadata 10.0 and document the shared protocols Oct 31, 2026
@bedevere-app bedevere-app Bot added the type-feature A feature request or enhancement label Oct 31, 2026
Comment thread Doc/library/importlib.metadata.rst Resolved
jaraco added a commit to python/importlib_metadata that referenced this pull request Nov 6, 2026
Documents the two class hierarchies, the protocols both satisfy, and
what that asks of consumers and of custom providers, following the
protocols and conformance-based warning added in #505. Moved here from
a draft against the stdlib docs (python/cpython#160344), where the
concern is largely this package's rather than the stdlib's.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The caveats are largely this backport's concern, so they now live in
its own documentation (python/importlib_metadata@be2ea93bc), which this
module links to from the overview, from IDistribution, and from the
custom provider example. What stays here is the documentation of the
protocols themselves.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@jaraco
jaraco marked this pull request as ready for review November 6, 2026 18:48
@jaraco
jaraco requested review from FFY00 and warsaw as code owners November 6, 2026 18:48
@jaraco
jaraco enabled auto-merge (squash) November 7, 2026 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review docs Documentation in the Doc dir type-feature A feature request or enhancement

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants