Skip to content

Commit ced832c

Browse files
Remove unnecessary entry_points wrapper for Python 3.10+
Since the project requires Python 3.10+, we no longer need a custom wrapper around importlib.metadata.entry_points(). In Python 3.10+, entry_points() natively supports the group= and name= parameters and returns EntryPoints directly. Changes: - Remove the entry_points() wrapper function from _entrypoints.py - Directly import and re-export entry_points from importlib.metadata - Update _discover.py to import EntryPoint type directly - Simplify type annotations by removing im.EntryPoint indirection All tests pass (296 passed, 5 skipped, 1 xfailed)
1 parent 97e5f11 commit ced832c

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

vcs-versioning/src/vcs_versioning/_discover.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import logging
44
import os
55
from collections.abc import Iterable, Iterator
6+
from importlib.metadata import EntryPoint
67
from pathlib import Path
78
from typing import TYPE_CHECKING
89

@@ -11,7 +12,7 @@
1112
from ._config import Configuration
1213

1314
if TYPE_CHECKING:
14-
from ._entrypoints import im
15+
pass
1516

1617

1718
log = logging.getLogger(__name__)
@@ -51,7 +52,7 @@ def match_entrypoint(root: _t.PathT, name: str) -> bool:
5152

5253
def iter_matching_entrypoints(
5354
root: _t.PathT, entrypoint: str, config: Configuration
54-
) -> Iterable[im.EntryPoint]:
55+
) -> Iterable[EntryPoint]:
5556
"""
5657
Consider different entry-points in ``root`` and optionally its parents.
5758
:param root: File path.

vcs-versioning/src/vcs_versioning/_entrypoints.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import logging
44
from collections.abc import Callable, Iterator
5+
from importlib import metadata as im
6+
from importlib.metadata import entry_points
57
from typing import TYPE_CHECKING, Any, cast
68

79
__all__ = [
@@ -13,22 +15,9 @@
1315
from . import _version_schemes
1416
from ._config import Configuration, ParseFunction
1517

16-
from importlib import metadata as im
17-
1818
log = logging.getLogger(__name__)
1919

2020

21-
def entry_points(*, group: str, name: str | None = None) -> im.EntryPoints:
22-
"""Get entry points for a specific group (and optionally name).
23-
24-
In Python 3.10+, entry_points() with group= returns EntryPoints directly.
25-
"""
26-
if name is not None:
27-
return im.entry_points(group=group, name=name)
28-
else:
29-
return im.entry_points(group=group)
30-
31-
3221
def version_from_entrypoint(
3322
config: Configuration, *, entrypoint: str, root: _t.PathT
3423
) -> _version_schemes.ScmVersion | None:

0 commit comments

Comments
 (0)