|
1 | 1 | import sys
|
2 | 2 | from typing import Any, Callable, Dict, List, TypeVar, Union
|
3 | 3 |
|
4 |
| -AnyCallableT = TypeVar("AnyCallableT", bound=Callable[..., Any]) # noqa: VNE001 |
5 |
| -# JSON primitives only, mypy doesn't support recursive tho |
6 |
| -JSONType = Union[str, int, float, bool, None, Dict[str, Any], List[Any]] |
| 4 | +if sys.version_info >= (3, 8): |
| 5 | + from typing import Literal, Protocol, TypedDict |
| 6 | +else: |
| 7 | + from typing_extensions import Literal, Protocol, TypedDict |
7 | 8 |
|
8 | 9 |
|
9 |
| -if sys.version_info >= (3, 8): |
10 |
| - from typing import Protocol |
| 10 | +if sys.version_info >= (3, 11): |
| 11 | + from typing import NotRequired |
11 | 12 | else:
|
12 |
| - from typing_extensions import Protocol |
| 13 | + from typing_extensions import NotRequired |
| 14 | + |
| 15 | + |
| 16 | +if sys.version_info >= (3, 10): |
| 17 | + from typing import TypeAlias |
| 18 | +else: |
| 19 | + from typing_extensions import TypeAlias |
| 20 | + |
| 21 | +AnyCallableT = TypeVar("AnyCallableT", bound=Callable[..., Any]) # noqa: VNE001 |
| 22 | +# JSON primitives only, mypy doesn't support recursive tho |
| 23 | +JSONType = Union[str, int, float, bool, None, Dict[str, Any], List[Any]] |
13 | 24 |
|
14 |
| -__all__ = ["Protocol"] |
| 25 | +__all__ = ["Protocol", "TypedDict", "Literal", "NotRequired", "TypeAlias"] |
0 commit comments