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

Use importlib.metadata (pygal requires 3.8+) #546

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 5 additions & 2 deletions pygal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import traceback
import warnings

from importlib_metadata import entry_points
from importlib.metadata import entry_points

from pygal import maps
from pygal.config import Config
Expand Down Expand Up @@ -62,7 +62,10 @@

from pygal.graph.map import BaseMap

for entry in entry_points(group="pygal.maps"):
for entry in entry_points():
# TODO: when targeting Python 3.10+, this can use `entry_points(group=...)`.
if entry.group != "pygal.maps":
continue
try:
module = entry.load()
except Exception:
Expand Down
7 changes: 5 additions & 2 deletions pygal/test/test_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
# along with pygal. If not, see <http://www.gnu.org/licenses/>.
"""Map plugins tests are imported here"""

from importlib_metadata import entry_points
from importlib.metadata import entry_points

# Load plugins tests
for entry in entry_points(group="pygal.test.test_maps"):
for entry in entry_points():
# TODO: when targeting Python 3.10+, this can use `entry_points(group=...)`.
if entry.group != "pygal.test.test_maps":
continue
module = entry.load()
for k, v in module.__dict__.items():
if k.startswith('test_'):
Expand Down
Loading