| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
"""Private helpers for the ``typing`` module.""" |
| 5 |
|
| 6 |
from __future__ import annotations |
| 7 |
|
| 8 |
TYPE_CHECKING = False |
| 9 |
if TYPE_CHECKING: |
| 10 |
import sys |
| 11 |
from collections.abc import Callable |
| 12 |
from typing import Any, Final, TypeVar, final, overload |
| 13 |
|
| 14 |
if sys.version_info[:2] >= (3, 11): |
| 15 |
from typing import Self |
| 16 |
else: |
| 17 |
from typing_extensions import Self |
| 18 |
|
| 19 |
if sys.version_info[:2] >= (3, 12): |
| 20 |
from typing import TypeAlias |
| 21 |
else: |
| 22 |
from typing_extensions import TypeAlias |
| 23 |
|
| 24 |
_F = TypeVar("_F", bound=Callable[..., Any]) |
| 25 |
_T = TypeVar('_T') |
| 26 |
else: |
| 27 |
|
| 28 |
|
| 29 |
def final(f: _T) -> _T: |
| 30 |
return f |
| 31 |
|
| 32 |
def _overload_inner(*args, **kwds): |
| 33 |
raise NotImplementedError |
| 34 |
|
| 35 |
|
| 36 |
def overload(func: _F) -> _F: |
| 37 |
return _overload_inner |
| 38 |
|
| 39 |
__all__: Final = ('final', 'overload') |