Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork93
Enforce local versions of objects#505
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
jaraco wants to merge12 commits intomainChoose a base branch frombugfix/486-local-objects
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.
+123 −1
Open
Changes fromall commits
Commits
Show all changes
12 commits Select commitHold shift + click to select a range
4261109 Add a couple of functions from jaraco.functools.
jaracoe36808d Create 'localize_dist' function to convert stdlib to local versions o…
jaraco6ff671d Create 'localize_metadata' function to normalize the outputs for .met…
jaraco5cd7d14 Create 'localize_package_path' function to convert stdlib to local ve…
jaraco374bd98 Add news fragment.
jaraco9000268 In localize_dist, cast the result to paper over an error.
jaraco1a30e01 Stop trying to differentiate between importlib.metadata._adapters.Mes…
jaraco5a67414 Suppress warnings when 'importlib_metadata' has been imported twice.
jaraco5a67a0d Suppress warning when CustomDistribution, derived from importlib.meta…
jaraco3dad754 Move _compat to its own package.
jaraco0ad266a Extract localize functions into their own module.
jaraco4a350a5 Rename 'localize.metadata' to 'localize.message'.
jaracoFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
7 changes: 6 additions & 1 deletionimportlib_metadata/__init__.py
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
File renamed without changes.
45 changes: 45 additions & 0 deletionsimportlib_metadata/_compat/localize.py
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,45 @@ | ||
| from __future__ import annotations | ||
| import email.message | ||
| import importlib.metadata | ||
| import warnings | ||
| from typing import cast | ||
| import importlib_metadata._adapters | ||
| def dist( | ||
| dist: importlib_metadata.Distribution | importlib.metadata.Distribution, | ||
| ) -> importlib_metadata.Distribution: | ||
| """ | ||
| Ensure dist is an :class:`importlib_metadata.Distribution`. | ||
| """ | ||
| if isinstance(dist, importlib_metadata.Distribution): | ||
| return dist | ||
| if isinstance(dist, importlib.metadata.PathDistribution): | ||
| return importlib_metadata.PathDistribution( | ||
| cast(importlib_metadata._meta.SimplePath, dist._path) | ||
| ) | ||
| # workaround for when pytest has replaced importlib_metadata | ||
| # https://github.com/python/importlib_metadata/pull/505#issuecomment-2344329001 | ||
| if dist.__class__.__module__ != 'importlib_metadata': | ||
| warnings.warn(f"Unrecognized distribution subclass {dist.__class__}") | ||
| return cast(importlib_metadata.Distribution, dist) | ||
| def message( | ||
| input: importlib_metadata._adapters.Message | email.message.Message, | ||
| ) -> importlib_metadata._adapters.Message: | ||
| if isinstance(input, importlib_metadata._adapters.Message): | ||
| return input | ||
| return importlib_metadata._adapters.Message(input) | ||
| def package_path( | ||
| input: importlib_metadata.PackagePath | importlib.metadata.PackagePath, | ||
| ) -> importlib_metadata.PackagePath: | ||
| if isinstance(input, importlib_metadata.PackagePath): | ||
| return input | ||
| replacement = importlib_metadata.PackagePath(input) | ||
| vars(replacement).update(vars(input)) | ||
| return replacement |
54 changes: 54 additions & 0 deletionsimportlib_metadata/_functools.py
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
1 change: 1 addition & 0 deletionsnewsfragments/486.removal.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 @@ | ||
| When providers supply objects from ``importlib.metadata``, they are now adapted to the classes from ``importlib_metadata``. |
17 changes: 17 additions & 0 deletionstests/compat/test_py39_compat.py
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
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.