|
1 | 1 | from collections.abc import Callable, Iterable
|
2 |
| -from typing import Any, TypeVar |
| 2 | +from typing import Any, TypeVar, Union |
| 3 | +from typing_extensions import TypeAlias |
3 | 4 |
|
4 | 5 | _F = TypeVar("_F", bound=Callable[..., Any])
|
| 6 | +_RaisesType: TypeAlias = Union[type[Exception], tuple[type[Exception], ...]] |
5 | 7 |
|
6 | 8 | class FormatChecker:
|
7 |
| - checkers: dict[str, tuple[Callable[[Any], bool], Exception | tuple[Exception, ...]]] |
| 9 | + checkers: dict[str, tuple[Callable[[Any], bool], _RaisesType]] |
8 | 10 |
|
9 | 11 | def __init__(self, formats: Iterable[str] | None = ...) -> None: ...
|
10 |
| - def checks(self, format: str, raises: Exception | tuple[Exception, ...] = ...) -> Callable[[_F], _F]: ... |
| 12 | + def checks(self, format: str, raises: _RaisesType = ...) -> Callable[[_F], _F]: ... |
11 | 13 | @classmethod
|
12 |
| - def cls_checks(cls, format: str, raises: Exception | tuple[Exception, ...] = ...) -> Callable[[_F], _F]: ... |
| 14 | + def cls_checks(cls, format: str, raises: _RaisesType = ...) -> Callable[[_F], _F]: ... |
13 | 15 | def check(self, instance: Any, format: str) -> None: ...
|
14 | 16 | def conforms(self, instance: Any, format: str) -> bool: ...
|
15 | 17 |
|
|
0 commit comments