Skip to content

Commit

Permalink
Remove a deprecated method from importlib_metadata (#991)
Browse files Browse the repository at this point in the history
* Remove a deprecated method

The dict interface from "importlib_metadata" is deprecated, so it must not be used as well.

* Upgrade the minimal `importlib_metadata` to 3.9.1

That way, the deprecated feature removed won't be harmful.

* Update pyface/base_toolkit.py

Convert a positional argument from "importlib_metadata.entry_points().select()" into a keyword argument.

Co-authored-by: Poruri Sai Rahul <rahul.poruri@gmail.com>

* Update pyface/base_toolkit.py

Convert a positional argument from "importlib_metadata.entry_points().select()" into a keyword argument.

Co-authored-by: Poruri Sai Rahul <rahul.poruri@gmail.com>

* Min required version is 3.6.0, not 3.9.0

the select interface was introduced in 3.6.0.
ref https://importlib-metadata.readthedocs.io/en/latest/history.html#v3-6-0

* The external package is now needed for python < 3.10

this is because the select interface isn't available in
any of the prior python versions

Co-authored-by: Poruri Sai Rahul <rahul.poruri@gmail.com>
  • Loading branch information
DiddiLeija and rahulporuri committed Jul 16, 2021
1 parent 3da9e6a commit dc10108
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
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)
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

0 comments on commit dc10108

Please sign in to comment.