Skip to content

Commit

Permalink
MAINT: update entry-points usage
Browse files Browse the repository at this point in the history
Co-authored-by: Nicholas Bollweg <nick.bollweg@gmail.com>
  • Loading branch information
agoose77 and bollwyvl committed Feb 21, 2024
1 parent fc9d465 commit e001397
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions jupyter_book/cli/pluggable.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@

import click

try:
from importlib import metadata
except ImportError:
import importlib_metadata as metadata
if __import__("sys").version_info < (3, 10):
from importlib_metadata import entry_points
else:
from importlib.metadata import entry_points

Check warning on line 9 in jupyter_book/cli/pluggable.py

View check run for this annotation

Codecov / codecov/patch

jupyter_book/cli/pluggable.py#L9

Added line #L9 was not covered by tests


def get_entry_point_names(group: str) -> List[str]:
return [ep.name for ep in metadata.entry_points().get(group, [])]
return [ep.name for ep in entry_points(group=group)]

Check warning on line 13 in jupyter_book/cli/pluggable.py

View check run for this annotation

Codecov / codecov/patch

jupyter_book/cli/pluggable.py#L13

Added line #L13 was not covered by tests


def load_entry_point(group: str, name: str) -> Any:
eps = [ep for ep in metadata.entry_points().get(group, []) if ep.name == name]
eps = [ep for ep in entry_points(group=group) if ep.name == name]

Check warning on line 17 in jupyter_book/cli/pluggable.py

View check run for this annotation

Codecov / codecov/patch

jupyter_book/cli/pluggable.py#L17

Added line #L17 was not covered by tests
if not eps:
raise KeyError(f"Entry-point {group}:{name}")
return eps[0].load()
Expand Down

0 comments on commit e001397

Please sign in to comment.