Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
_pep440.pyi119 linesDownload Raw Back to _utils
1import re
2from collections.abc import Callable
3from typing import (
4    Any,
5    ClassVar,
6    Final,
7    Generic,
8    Literal as L,
9    NamedTuple,
10    TypeVar,
11    final,
12    type_check_only,
13)
14from typing_extensions import TypeIs
15
16__all__ = ["VERSION_PATTERN", "InvalidVersion", "LegacyVersion", "Version", "parse"]
17
18###
19
20_CmpKeyT = TypeVar("_CmpKeyT", bound=tuple[object, ...])
21_CmpKeyT_co = TypeVar("_CmpKeyT_co", bound=tuple[object, ...], default=tuple[Any, ...], covariant=True)
22
23###
24
25VERSION_PATTERN: Final[str] = ...
26
27class InvalidVersion(ValueError): ...
28
29@type_check_only
30@final
31class _InfinityType:
32    def __hash__(self) -> int: ...
33    def __eq__(self, other: object, /) -> TypeIs[_InfinityType]: ...
34    def __ne__(self, other: object, /) -> bool: ...
35    def __lt__(self, other: object, /) -> L[False]: ...
36    def __le__(self, other: object, /) -> L[False]: ...
37    def __gt__(self, other: object, /) -> L[True]: ...
38    def __ge__(self, other: object, /) -> L[True]: ...
39    def __neg__(self) -> _NegativeInfinityType: ...
40
41Infinity: Final[_InfinityType] = ...
42
43@type_check_only
44@final
45class _NegativeInfinityType:
46    def __hash__(self) -> int: ...
47    def __eq__(self, other: object, /) -> TypeIs[_NegativeInfinityType]: ...
48    def __ne__(self, other: object, /) -> bool: ...
49    def __lt__(self, other: object, /) -> L[True]: ...
50    def __le__(self, other: object, /) -> L[True]: ...
51    def __gt__(self, other: object, /) -> L[False]: ...
52    def __ge__(self, other: object, /) -> L[False]: ...
53    def __neg__(self) -> _InfinityType: ...
54
55NegativeInfinity: Final[_NegativeInfinityType] = ...
56
57class _Version(NamedTuple):
58    epoch: int
59    release: tuple[int, ...]
60    dev: tuple[str, int] | None
61    pre: tuple[str, int] | None
62    post: tuple[str, int] | None
63    local: tuple[str | int, ...] | None
64
65class _BaseVersion(Generic[_CmpKeyT_co]):
66    _key: _CmpKeyT_co
67    def __hash__(self) -> int: ...
68    def __eq__(self, other: _BaseVersion, /) -> bool: ...  # type: ignore[override]  # pyright: ignore[reportIncompatibleMethodOverride]
69    def __ne__(self, other: _BaseVersion, /) -> bool: ...  # type: ignore[override]  # pyright: ignore[reportIncompatibleMethodOverride]
70    def __lt__(self, other: _BaseVersion, /) -> bool: ...
71    def __le__(self, other: _BaseVersion, /) -> bool: ...
72    def __ge__(self, other: _BaseVersion, /) -> bool: ...
73    def __gt__(self, other: _BaseVersion, /) -> bool: ...
74    def _compare(self, /, other: _BaseVersion[_CmpKeyT], method: Callable[[_CmpKeyT_co, _CmpKeyT], bool]) -> bool: ...
75
76class LegacyVersion(_BaseVersion[tuple[L[-1], tuple[str, ...]]]):
77    _version: Final[str]
78    def __init__(self, /, version: str) -> None: ...
79    @property
80    def public(self) -> str: ...
81    @property
82    def base_version(self) -> str: ...
83    @property
84    def local(self) -> None: ...
85    @property
86    def is_prerelease(self) -> L[False]: ...
87    @property
88    def is_postrelease(self) -> L[False]: ...
89
90class Version(
91    _BaseVersion[
92        tuple[
93            int,  # epoch
94            tuple[int, ...],  # release
95            tuple[str, int] | _InfinityType | _NegativeInfinityType,  # pre
96            tuple[str, int] | _NegativeInfinityType,  # post
97            tuple[str, int] | _InfinityType,  # dev
98            tuple[tuple[int, L[""]] | tuple[_NegativeInfinityType, str], ...] | _NegativeInfinityType,  # local
99        ],
100    ],
101):
102    _regex: ClassVar[re.Pattern[str]] = ...
103    _version: Final[str]
104
105    def __init__(self, /, version: str) -> None: ...
106    @property
107    def public(self) -> str: ...
108    @property
109    def base_version(self) -> str: ...
110    @property
111    def local(self) -> str | None: ...
112    @property
113    def is_prerelease(self) -> bool: ...
114    @property
115    def is_postrelease(self) -> bool: ...
116
117#
118def parse(version: str) -> Version | LegacyVersion: ...
119 
codekingpro/portable-devtools · Team Ai