diff --git a/stdlib/2and3/distutils/version.pyi b/stdlib/2and3/distutils/version.pyi index d44a6f2ee3a9..956273542e6f 100644 --- a/stdlib/2and3/distutils/version.pyi +++ b/stdlib/2and3/distutils/version.pyi @@ -1,31 +1,54 @@ import sys -from typing import Any +from abc import abstractmethod +from typing import Any, Optional, TypeVar, Union, Pattern, Tuple + +_T = TypeVar('_T', bound='Version') class Version: - def __init__(self, vstring=None): ... + def __repr__(self) -> str: ... + + if sys.version_info >= (3,): + def __eq__(self, other: object) -> bool: ... + def __lt__(self: _T, other: Union[_T, str]) -> bool: ... + def __le__(self: _T, other: Union[_T, str]) -> bool: ... + def __gt__(self: _T, other: Union[_T, str]) -> bool: ... + def __ge__(self: _T, other: Union[_T, str]) -> bool: ... + @abstractmethod + def __init__(self, vstring: Optional[str] = ...) -> None: ... + @abstractmethod + def parse(self: _T, vstring: str) -> _T: ... + @abstractmethod + def __str__(self) -> str: ... if sys.version_info >= (3,): - def __eq__(self, other): ... - def __lt__(self, other): ... - def __le__(self, other): ... - def __gt__(self, other): ... - def __ge__(self, other): ... + @abstractmethod + def _cmp(self: _T, other: Union[_T, str]) -> bool: ... + else: + @abstractmethod + def __cmp__(self: _T, other: Union[_T, str]) -> bool: ... class StrictVersion(Version): - version_re = ... # type: Any - version = ... # type: Any - prerelease = ... # type: Any - def parse(self, vstring): ... + version_re: Pattern[str] + version: Tuple[int, int, int] + prerelease: Optional[Tuple[str, int]] - if sys.version_info < (3,): - def __cmp__(self, other): ... + def __init__(self, vstring: Optional[str] = ...) -> None: ... + def parse(self: _T, vstring: str) -> _T: ... + def __str__(self) -> str: ... + if sys.version_info >= (3,): + def _cmp(self: _T, other: Union[_T, str]) -> bool: ... + else: + def __cmp__(self: _T, other: Union[_T, str]) -> bool: ... class LooseVersion(Version): - component_re = ... # type: Any - def __init__(self, vstring=None): ... - vstring = ... # type: Any - version = ... # type: Any - def parse(self, vstring): ... - - if sys.version_info < (3,): - def __cmp__(self, other): ... + component_re: Pattern[str] + vstring: str + version: Tuple[Union[str, int], ...] + + def __init__(self, vstring: Optional[str] = ...) -> None: ... + def parse(self: _T, vstring: str) -> _T: ... + def __str__(self) -> str: ... + if sys.version_info >= (3,): + def _cmp(self: _T, other: Union[_T, str]) -> bool: ... + else: + def __cmp__(self: _T, other: Union[_T, str]) -> bool: ...