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 — gh-160386: Apply changes from importlib_metadata 10.0 and document the shared protocols by jaraco · Pull Request #160344 · python/cpython

Conversation

@jaraco

@jaraco jaraco commented Oct 22, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

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

  • Issue: Sync with importlib_metadata for Python 3.16 #160386

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jaraco @claude
pythongh-123976: Document backport caveats for custom providers
ac1128a
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]>
@bedevere-app bedevere-app Bot added the docs Documentation in the Doc dir label Oct 22, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Oct 22, 2026
Expand documentation for importlib.metadata custom providers to include caveats regarding backports #123976
Open
2 tasks
@github-project-automation github-project-automation Bot added this to Docs PRs Oct 22, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Docs PRs Oct 22, 2026
@jaraco jaraco mentioned this pull request Oct 22, 2026
Enforce local versions of objects and introduce shared protocols python/importlib_metadata#505
Merged
@read-the-docs-community

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

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Documentation build overview

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

  🔍 Preview build  

160 files changed · ± 160 modified

± Modified

  • glossary.html
  • builtins/exceptions.html
  • builtins/functions.html
  • builtins/stdtypes.html
  • builtins/threadsafety.html
  • c-api/bool.html
  • c-api/buffer.html
  • c-api/bytes.html
  • c-api/code.html
  • c-api/codec.html
  • and 150 more...
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jaraco @claude
pythongh-123976: Warn only on an incomplete provider
ab57ac7
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
jaraco commented Oct 22, 2026
View reviewed changes
Comment thread Doc/library/importlib.metadata.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

jaraco
jaraco commented Oct 22, 2026
View reviewed changes
Comment thread Doc/library/importlib.metadata.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

jaraco and others added 2 commits October 22, 2026 14:51
@jaraco @claude
pythongh-123976: Separate the consumer and provider caveats
69a4d48
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]>
@jaraco @claude
pythongh-123976: Document the protocols shared with the backport
be9a5de
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]>
@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
@jaraco
Merge remote-tracking branch 'upstream/main' into docs/pythongh-123976-…
ce987c6
…backport-caveats
@jaraco @claude
pythongh-160386: Apply changes from importlib_metadata 10.0
294c0df
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 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
@bedevere-app bedevere-app Bot mentioned this pull request Oct 31, 2026
Sync with importlib_metadata for Python 3.16 #160386
Open
jaraco
jaraco commented Nov 6, 2026
View reviewed changes
Comment thread Doc/library/importlib.metadata.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

jaraco added a commit to python/importlib_metadata that referenced this pull request Nov 6, 2026
@jaraco @claude
Add a caveats page describing interoperation with importlib.metadata.
be2ea93
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]>
@jaraco @claude
pythongh-123976: Move the backport caveats to the backport's docs
cb1a2b7
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]>
@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
@bedevere-app bedevere-app Bot added the awaiting core review label Nov 6, 2026
@warsaw
Merge branch 'main' into docs/pythongh-123976-backport-caveats
f234adb
@jaraco
jaraco enabled auto-merge (squash) November 7, 2026 14:05
@warsaw

warsaw commented Nov 7, 2026

Copy link
Copy Markdown
Member

@jaraco While I think it's a worthy goal to enable type checks in a way that bridges the gap between the stdlib API and the backport API, I have some concerns about backward compatibility. Changing the types can potentially break existing code, so I had my agent help with an analysis.

The IPackagePath protocol is narrower than PackagePath objects. PackagePath is documented as a PurePath, and code like [f for f in files('pkg') if f.suffix == '.py'], or anything using name, stem, parent, match(), or /, would no longer type check against the new annotations once typeshed adopts the new types.

Both libraries' PackagePath derive from PurePosixPath, so the protocol could declare that interface (or at least the commonly used members) without weakening the cross-library guarantee. There's nothing public in pathlib to compose with: pathlib.types._JoinablePath is private, an ABC rather than a protocol, and absent before 3.14, so the members would need to be declared on IPackagePath directly. Since 10.0 has already shipped, this would presumably go to importlib_metadata first and then be synced here.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

warsaw
warsaw requested changes Nov 7, 2026
View reviewed changes
Comment thread Lib/test/test_importlib/metadata/test_protocols.py
assert isinstance(metadata('distinfo-pkg'), PackageMetadata)

def test_package_path_matches_protocol(self):
assert all(isinstance(file, IPackagePath) for file in files('distinfo-pkg'))

@warsaw warsaw Nov 7, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This covers objects that came from files(), but a directly constructed PackagePath doesn't
satisfy the protocol:

>>> isinstance(PackagePath('foo.py'), IPackagePath)
False

hash, size, and dist are only set on instances in make_file(). The doctests on _get_toplevel_name(), now annotated IPackagePath, pass exactly such objects. Since the docs now steer users toward the protocols, it would be good to either give PackagePath class-level defaults for those attributes or note the limitation in the IPackagePath docs. A test for whichever behavior is intended would help too.

See my general comment below.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot removed the awaiting core review label Nov 7, 2026
@bedevere-app bedevere-app Bot added the awaiting changes label Nov 7, 2026
@bedevere-app

bedevere-app Bot commented Nov 7, 2026

Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

Reviewers

@warsaw warsaw warsaw requested changes
@FFY00 FFY00 Awaiting requested review from FFY00 FFY00 is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

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

Projects

Docs PRs
Status: Todo

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@jaraco @warsaw
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.
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.