Skip to content

Commit

Permalink
Use importlib.metadata (pygal requires 3.8+)
Browse files Browse the repository at this point in the history
  • Loading branch information
akx committed Nov 21, 2023
1 parent fc7d69c commit 6cef48e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
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

0 comments on commit 6cef48e

Please sign in to comment.