File: _typing.py

package info (click to toggle)
python-docutils 0.22%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 11,448 kB
  • sloc: python: 53,302; lisp: 14,475; xml: 1,807; javascript: 1,032; makefile: 102; sh: 96
file content (39 lines) | stat: -rw-r--r-- 1,062 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Copyright: This module has been placed in the public domain.
# Author: Adam Turner

"""Private helpers for the ``typing`` module."""

from __future__ import annotations

TYPE_CHECKING = False
if TYPE_CHECKING:
    import sys
    from collections.abc import Callable
    from typing import Any, Final, TypeVar, final, overload

    if sys.version_info[:2] >= (3, 11):
        from typing import Self
    else:
        from typing_extensions import Self  # NoQA: F401

    if sys.version_info[:2] >= (3, 12):
        from typing import TypeAlias
    else:
        from typing_extensions import TypeAlias  # NoQA: F401

    _F = TypeVar("_F", bound=Callable[..., Any])
    _T = TypeVar('_T')
else:

    # Runtime replacement for ``typing.final``.
    def final(f: _T) -> _T:
        return f

    def _overload_inner(*args, **kwds):
        raise NotImplementedError

    # Runtime replacement for ``typing.overload``.
    def overload(func: _F) -> _F:
        return _overload_inner

__all__: Final = ('final', 'overload')