Repository navigation
Conversation
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 <[email protected]>
2 tasks
Documentation build overview
160 files changed ·
|
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 <[email protected]>
jaraco
commented
Oct 22, 2026
jaraco
commented
Oct 22, 2026
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
jaraco
commented
Nov 6, 2026
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 <[email protected]>
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 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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):
IDistributionandIPackagePathprotocols in_meta.py, both@runtime_checkable, exported fromimportlib.metadata. Thecompatand_compatpackages, which holdlocalizeand the warning it raises for aprovider's incomplete
Distributionsubclass, are excluded from the port asusual, so only the protocols arrive here.
Documentation (gh-123976)
IDistributionandIPackagePath.PackageMetadataentry, which described itself as "a concreteimplementation of the PackageMetadata protocol" and linked to the backport's
docs for the protocol.
importlib.metadata._meta.PackageMetadatais itself aProtocol, and is exported in__all__.Caveats
page from the overview's
seealso, fromIDistribution, and from the customprovider 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