-
Notifications
You must be signed in to change notification settings - Fork 264
Dependency upgrade/cleanup after dropping py3.9 #7245
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
Merged
Merged
Changes from all commits
Commits
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
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
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 |
|---|---|---|
|
|
@@ -21,10 +21,7 @@ | |
| from . import factories | ||
|
|
||
| if TYPE_CHECKING: | ||
| # importlib.metadata was introduced into the standard library in python 3.8, | ||
| # but was then updated in python 3.10 to use an improved API. | ||
| # So for now we use the backport importlib_metadata package. | ||
| from importlib_metadata import EntryPoint, EntryPoints | ||
| from importlib.metadata import EntryPoint, EntryPoints | ||
|
|
||
| __all__ = ('get_entry_points', 'load_entry_point', 'load_entry_point_from_string', 'parse_entry_point') | ||
|
|
||
|
|
@@ -43,9 +40,16 @@ def eps() -> EntryPoints: | |
| which will always iterate over all entry points since it looks for | ||
| possible duplicate entries. | ||
| """ | ||
| from importlib_metadata import EntryPoints, entry_points | ||
|
|
||
| all_eps = entry_points() | ||
| import sys | ||
| from importlib.metadata import EntryPoints, entry_points | ||
|
|
||
| all_eps: list[EntryPoint] | EntryPoints | ||
| if sys.version_info >= (3, 12): | ||
| all_eps = entry_points() | ||
| else: | ||
| # Python <3.12: entry_points() returns SelectableGroups (dict subclass) | ||
| # that iterates group names, not EntryPoints. Flatten via .values(). | ||
| all_eps = [ep for group_eps in entry_points().values() for ep in group_eps] | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Had to iterate through this logic multiple times. I think this is the clearest way. Its a bit annoying but I think its worse the dependency drop.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| return EntryPoints(sorted(all_eps, key=lambda x: x.group)) | ||
|
|
||
|
|
||
|
|
@@ -154,7 +158,7 @@ class EntryPointFormat(enum.Enum): | |
|
|
||
| def parse_entry_point(group: str, spec: str) -> EntryPoint: | ||
| """Return an entry point, given its group and spec (as formatted in the setup)""" | ||
| from importlib_metadata import EntryPoint | ||
| from importlib.metadata import EntryPoint | ||
|
|
||
| name, value = spec.split('=', maxsplit=1) | ||
| return EntryPoint(group=group, name=name.strip(), value=value.strip()) | ||
|
|
||
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
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
Oops, something went wrong.
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.
One more thing like this: Move
TypeAliasimport fromtyping_extensionstotypinginaiida/tools/graph/age_entities.pyThere 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.
So I only changed it in
src/aiida/engine/processes/functions.pyand not in the other file. There will be a larger PR where we will usepyupgradeto automatically update every source file to 3.10 syntax and this will include also changes as removingtyping_extensionsimports if it is not done automatically by the tool. We want to do this right before the next minor release because it would create a lot of annoying diff noise resulting in a loft of merge conflicts for the patch releases of 2.8.x that still supports 3.9. Insrc/aiida/engine/processes/functions.pywe already changed this part of the code so it will probably anyway result in a merge conflict. Hope this is okay.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.
Sure, fair enough!