Skip to content
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

Remove a deprecated method from importlib_metadata #991

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyface/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


__requires__ = [
'importlib-metadata; python_version<"3.8"',
'importlib-metadata>=3.6.0; python_version<"3.10"',
'importlib-resources>=1.1.0; python_version<"3.9"',
"traits>=6.2"
]
Expand Down
4 changes: 2 additions & 2 deletions pyface/base_toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def import_toolkit(toolkit_name, entry_point="pyface.toolkits"):
If no toolkit is found, or if the toolkit cannot be loaded for some
reason.
"""
entry_point_group = importlib_metadata.entry_points()[entry_point]
entry_point_group = importlib_metadata.entry_points().select(group=entry_point)
Copy link
Member

Choose a reason for hiding this comment

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

Unfortunately, this code fails on newer Python versions, where import importlib.metadata as importlib_metadata is used: the return value from entry_points() is then a plain dict, which doesn't have a select method.

Copy link
Member

Choose a reason for hiding this comment

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

I've opened #998 to track this. It might also be good to see if we can get the CI tests running on Python 3.9, so that this sort of failure is detected earlier.

plugins = [
plugin for plugin in entry_point_group if plugin.name == toolkit_name
]
Expand Down Expand Up @@ -256,7 +256,7 @@ def find_toolkit(entry_point, toolkits=None, priorities=default_priorities):
return import_toolkit(ETSConfig.toolkit, entry_point)

entry_points = [
plugin for plugin in importlib_metadata.entry_points()[entry_point]
plugin for plugin in importlib_metadata.entry_points().select(group=entry_point)
if toolkits is None or plugin.name in toolkits
]
for plugin in sorted(entry_points, key=priorities):
Expand Down