summaryrefslogtreecommitdiff
path: root/src/setuptools_scm/_types.py
blob: 555b1e754da211da48c165fde074add71edb0619 (plain)
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
40
41
42
43
44
45
46
47
48
49
from __future__ import annotations

from typing import Any
from typing import Callable
from typing import List
from typing import NamedTuple
from typing import TYPE_CHECKING
from typing import TypeVar
from typing import Union


if TYPE_CHECKING:
    from setuptools_scm import version
    import os

from typing_extensions import ParamSpec, TypeAlias, Protocol

PathT = Union["os.PathLike[str]", str]

CMD_TYPE: TypeAlias = Union[List[str], str]

VERSION_SCHEME = Union[str, Callable[["version.ScmVersion"], str]]


class CmdResult(NamedTuple):
    out: str
    err: str
    returncode: int


class EntrypointProtocol(Protocol):
    name: str

    def load(self) -> Any:
        pass


T = TypeVar("T")
T2 = TypeVar("T2")
P = ParamSpec("P")


def transfer_input_args(
    template: Callable[P, T],
) -> Callable[[Callable[..., T]], Callable[P, T]]:
    def decorate(func: Callable[..., T2]) -> Callable[P, T2]:
        return func

    return decorate