Skip to content

Commit

Permalink
Use entry-points-selectable compatibility shim.
Browse files Browse the repository at this point in the history
Adds forward-compatibility for entry_points.
Fixes deprecation warnings.
See: python/importlib_metadata#298
  • Loading branch information
martinhoyer committed May 22, 2023
1 parent fc0d900 commit 3216f0a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Expand Up @@ -27,7 +27,7 @@ module = [
"nitrate.*",
"pylero.*",
"testcloud.*",
"importlib_metadata",
"backports.entry_points_selectable",
"mrack.*",
]
ignore_missing_imports = true
Expand Down
4 changes: 1 addition & 3 deletions setup.py
Expand Up @@ -56,6 +56,7 @@
'ruamel.yaml',
'jinja2',
'setuptools',
'backports.entry_points_selectable', # Required for importlib_metadata < 3.6 (Python < 3.10)
]

# typing_extensions is needed with Python 3.7 and older, types imported
Expand All @@ -66,9 +67,6 @@
# dataclasses is needed with Python 3.6
install_requires.append("dataclasses; python_version < '3.7'")

# entry_points is part of Python 3.9+
install_requires.append("importlib_metadata; python_version < '3.9'")

extras_require = {
'docs': [
'sphinx>=3',
Expand Down
7 changes: 2 additions & 5 deletions tmt/plugins/__init__.py
Expand Up @@ -8,10 +8,7 @@
import sys
from typing import Any, Generator, List, Optional, Tuple

if sys.version_info < (3, 9):
from importlib_metadata import entry_points
else:
from importlib.metadata import entry_points
from backports.entry_points_selectable import entry_points

import tmt
from tmt.log import Logger
Expand Down Expand Up @@ -115,7 +112,7 @@ def _explore_entry_point(entry_point: str, logger: Logger) -> None:
logger = logger.descend()

try:
for found in entry_points()[entry_point]:
for found in entry_points(group=entry_point):
logger.debug(f"Loading plugin '{found.name}' ({found.value}).")
found.load()

Expand Down

0 comments on commit 3216f0a

Please sign in to comment.