Repository navigation
gh-160386: Apply changes from importlib_metadata 10.0 and document the shared protocols #160344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jaraco
wants to merge
8
commits into
python:main
Choose a base branch
from
jaraco:docs/gh-123976-backport-caveats
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+167
−20
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ac1128a
gh-123976: Document backport caveats for custom providers
jaraco ab57ac7
gh-123976: Warn only on an incomplete provider
jaraco 69a4d48
gh-123976: Separate the consumer and provider caveats
jaraco be9a5de
gh-123976: Document the protocols shared with the backport
jaraco ce987c6
Merge remote-tracking branch 'upstream/main' into docs/gh-123976-back…
jaraco 294c0df
gh-160386: Apply changes from importlib_metadata 10.0
jaraco cb1a2b7
gh-123976: Move the backport caveats to the backport's docs
jaraco f234adb
Merge branch 'main' into docs/gh-123976-backport-caveats
warsaw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import unittest | ||
|
|
||
| from importlib.metadata import ( | ||
| IDistribution, | ||
| IPackagePath, | ||
| PackageMetadata, | ||
| distribution, | ||
| files, | ||
| metadata, | ||
| ) | ||
|
|
||
| from . import fixtures | ||
|
|
||
|
|
||
| class ProtocolTests(fixtures.DistInfoPkg, unittest.TestCase): | ||
| """ | ||
| The objects supplied to consumers satisfy the published protocols. | ||
| """ | ||
|
|
||
| def test_distribution_matches_protocol(self): | ||
| assert isinstance(distribution('distinfo-pkg'), IDistribution) | ||
|
|
||
| def test_metadata_matches_protocol(self): | ||
| assert isinstance(metadata('distinfo-pkg'), PackageMetadata) | ||
|
|
||
| def test_package_path_matches_protocol(self): | ||
| assert all(isinstance(file, IPackagePath) for file in files('distinfo-pkg')) | ||
3 changes: 3 additions & 0 deletions
3
Misc/NEWS.d/next/Documentation/2026-10-22-18-51-05.gh-issue-123976.GKLjFT.rst
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Document the ``IDistribution`` and ``IPackagePath`` protocols, which | ||
| ``importlib.metadata`` shares with the ``importlib_metadata`` backport, and | ||
| correct ``PackageMetadata``, which is itself such a protocol. |
6 changes: 6 additions & 0 deletions
6
Misc/NEWS.d/next/Library/2026-10-31-15-50-12.gh-issue-160386.qRrnCh.rst
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| Applied changes to ``importlib.metadata`` from `importlib_metadata 10.0 | ||
| <https://importlib-metadata.readthedocs.io/en/latest/history.html#v10-0-0>`_: | ||
| added the ``IDistribution`` and ``IPackagePath`` protocols, so a consumer can | ||
| target one interface across ``importlib.metadata`` and the backport rather | ||
| than either library's concrete classes, and the functions returning | ||
| distributions and files are annotated with them. |
Oops, something went wrong.
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.
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 constructedPackagePathdoesn'tsatisfy the protocol:
hash,size, anddistare only set on instances inmake_file(). The doctests on_get_toplevel_name(), now annotatedIPackagePath, pass exactly such objects. Since the docs now steer users toward the protocols, it would be good to either givePackagePathclass-level defaults for those attributes or note the limitation in theIPackagePathdocs. A test for whichever behavior is intended would help too.See my general comment below.