|
1 | 1 | from __future__ import annotations
|
2 | 2 |
|
| 3 | +import importlib.metadata |
3 | 4 | import inspect
|
4 |
| -import sys |
5 | 5 | import types
|
6 | 6 | import warnings
|
7 | 7 | from typing import Any
|
8 | 8 | from typing import Callable
|
9 | 9 | from typing import cast
|
| 10 | +from typing import Final |
10 | 11 | from typing import Iterable
|
11 | 12 | from typing import Mapping
|
12 | 13 | from typing import Sequence
|
13 |
| -from typing import TYPE_CHECKING |
14 | 14 |
|
15 | 15 | from . import _tracing
|
16 | 16 | from ._callers import _multicall
|
17 | 17 | from ._hooks import _HookCaller
|
18 | 18 | from ._hooks import _HookImplFunction
|
| 19 | +from ._hooks import _HookImplOpts |
19 | 20 | from ._hooks import _HookRelay
|
| 21 | +from ._hooks import _HookSpecOpts |
20 | 22 | from ._hooks import _Namespace
|
21 | 23 | from ._hooks import _Plugin
|
22 | 24 | from ._hooks import _SubsetHookCaller
|
|
25 | 27 | from ._hooks import normalize_hookimpl_opts
|
26 | 28 | from ._result import _Result
|
27 | 29 |
|
28 |
| -if sys.version_info >= (3, 8): |
29 |
| - from importlib import metadata as importlib_metadata |
30 |
| -else: |
31 |
| - import importlib_metadata |
32 |
| - |
33 |
| -if TYPE_CHECKING: |
34 |
| - from typing_extensions import Final |
35 |
| - |
36 |
| - from ._hooks import _HookImplOpts, _HookSpecOpts |
37 | 30 |
|
38 | 31 | _BeforeTrace = Callable[[str, Sequence[HookImpl], Mapping[str, Any]], None]
|
39 | 32 | _AfterTrace = Callable[[_Result[Any], str, Sequence[HookImpl], Mapping[str, Any]], None]
|
@@ -63,7 +56,7 @@ def __init__(self, plugin: _Plugin, message: str) -> None:
|
63 | 56 | class DistFacade:
|
64 | 57 | """Emulate a pkg_resources Distribution"""
|
65 | 58 |
|
66 |
| - def __init__(self, dist: importlib_metadata.Distribution) -> None: |
| 59 | + def __init__(self, dist: importlib.metadata.Distribution) -> None: |
67 | 60 | self._dist = dist
|
68 | 61 |
|
69 | 62 | @property
|
@@ -351,7 +344,7 @@ def load_setuptools_entrypoints(self, group: str, name: str | None = None) -> in
|
351 | 344 | :return: The number of plugins loaded by this call.
|
352 | 345 | """
|
353 | 346 | count = 0
|
354 |
| - for dist in list(importlib_metadata.distributions()): |
| 347 | + for dist in list(importlib.metadata.distributions()): |
355 | 348 | for ep in dist.entry_points:
|
356 | 349 | if (
|
357 | 350 | ep.group != group
|
|
0 commit comments