Skip to content

Refine types for distutils.version #1835

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 44 additions & 21 deletions stdlib/2and3/distutils/version.pyi
Original file line number Diff line number Diff line change
@@ -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: ...