|
4 | 4 |
|
5 | 5 | from __future__ import annotations |
6 | 6 |
|
| 7 | +from collections.abc import Callable |
7 | 8 | from collections.abc import Generator |
8 | 9 | from collections.abc import Mapping |
9 | 10 | from collections.abc import Sequence |
|
12 | 13 | import sys |
13 | 14 | from types import ModuleType |
14 | 15 | from typing import Any |
15 | | -from typing import Callable |
16 | 16 | from typing import Final |
17 | 17 | from typing import final |
18 | | -from typing import Optional |
19 | 18 | from typing import overload |
20 | 19 | from typing import TYPE_CHECKING |
| 20 | +from typing import TypeAlias |
21 | 21 | from typing import TypedDict |
22 | 22 | from typing import TypeVar |
23 | | -from typing import Union |
24 | 23 | import warnings |
25 | 24 |
|
26 | 25 | from ._result import Result |
27 | 26 |
|
28 | 27 |
|
29 | 28 | _T = TypeVar("_T") |
30 | 29 | _F = TypeVar("_F", bound=Callable[..., object]) |
31 | | -_Namespace = Union[ModuleType, type] |
32 | | -_Plugin = object |
33 | | -_HookExec = Callable[ |
| 30 | + |
| 31 | +_Namespace: TypeAlias = ModuleType | type |
| 32 | +_Plugin: TypeAlias = object |
| 33 | +_HookExec: TypeAlias = Callable[ |
34 | 34 | [str, Sequence["HookImpl"], Mapping[str, object], bool], |
35 | | - Union[object, list[object]], |
| 35 | + object | list[object], |
36 | 36 | ] |
37 | | -_HookImplFunction = Callable[..., Union[_T, Generator[None, Result[_T], None]]] |
| 37 | +_HookImplFunction: TypeAlias = Callable[..., _T | Generator[None, Result[_T], None]] |
38 | 38 |
|
39 | 39 |
|
40 | 40 | class HookspecOpts(TypedDict): |
@@ -374,7 +374,9 @@ def __getattr__(self, name: str) -> HookCaller: ... |
374 | 374 | _HookRelay = HookRelay |
375 | 375 |
|
376 | 376 |
|
377 | | -_CallHistory = list[tuple[Mapping[str, object], Optional[Callable[[Any], None]]]] |
| 377 | +_CallHistory: TypeAlias = list[ |
| 378 | + tuple[Mapping[str, object], Callable[[Any], None] | None] |
| 379 | +] |
378 | 380 |
|
379 | 381 |
|
380 | 382 | class HookCaller: |
|
0 commit comments