Akuli and srittau: Remove Python 2 branches from Python 3 stubs (#5461)

* run script and do some manual changes (Akuli)

* do the whole thing manually (srittau)

* merge changes (Akuli)

Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
This commit is contained in:
Akuli
2021-05-15 15:33:39 +03:00
committed by GitHub
parent b0ef85288d
commit 17dcea4a68
106 changed files with 1539 additions and 3275 deletions

View File

@@ -1,14 +1,10 @@
import numbers
import sys
from types import TracebackType
from typing import Any, Container, Dict, List, NamedTuple, Optional, Sequence, Text, Tuple, Type, TypeVar, Union, overload
_Decimal = Union[Decimal, int]
_DecimalNew = Union[Decimal, float, Text, Tuple[int, Sequence[int], int]]
if sys.version_info >= (3,):
_ComparableNum = Union[Decimal, float, numbers.Rational]
else:
_ComparableNum = Union[Decimal, float]
_ComparableNum = Union[Decimal, float, numbers.Rational]
_DecimalT = TypeVar("_DecimalT", bound=Decimal)
class DecimalTuple(NamedTuple):
@@ -25,17 +21,13 @@ ROUND_UP: str
ROUND_HALF_DOWN: str
ROUND_05UP: str
if sys.version_info >= (3,):
HAVE_THREADS: bool
MAX_EMAX: int
MAX_PREC: int
MIN_EMIN: int
MIN_ETINY: int
class DecimalException(ArithmeticError):
if sys.version_info < (3,):
def handle(self, context: Context, *args: Any) -> Optional[Decimal]: ...
HAVE_THREADS: bool
MAX_EMAX: int
MAX_PREC: int
MIN_EMIN: int
MIN_ETINY: int
class DecimalException(ArithmeticError): ...
class Clamped(DecimalException): ...
class InvalidOperation(DecimalException): ...
class ConversionSyntax(InvalidOperation): ...
@@ -48,9 +40,7 @@ class Rounded(DecimalException): ...
class Subnormal(DecimalException): ...
class Overflow(Inexact, Rounded): ...
class Underflow(Inexact, Rounded, Subnormal): ...
if sys.version_info >= (3,):
class FloatOperation(DecimalException, TypeError): ...
class FloatOperation(DecimalException, TypeError): ...
def setcontext(__context: Context) -> None: ...
def getcontext() -> Context: ...
@@ -60,69 +50,36 @@ class Decimal(object):
def __new__(cls: Type[_DecimalT], value: _DecimalNew = ..., context: Optional[Context] = ...) -> _DecimalT: ...
@classmethod
def from_float(cls, __f: float) -> Decimal: ...
if sys.version_info >= (3,):
def __bool__(self) -> bool: ...
else:
def __nonzero__(self) -> bool: ...
def __div__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def __rdiv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def __ne__(self, other: object, context: Optional[Context] = ...) -> bool: ...
def __bool__(self) -> bool: ...
def compare(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def __hash__(self) -> int: ...
def as_tuple(self) -> DecimalTuple: ...
if sys.version_info >= (3, 6):
def as_integer_ratio(self) -> Tuple[int, int]: ...
def as_integer_ratio(self) -> Tuple[int, int]: ...
def to_eng_string(self, context: Optional[Context] = ...) -> str: ...
if sys.version_info >= (3,):
def __abs__(self) -> Decimal: ...
def __add__(self, other: _Decimal) -> Decimal: ...
def __divmod__(self, other: _Decimal) -> Tuple[Decimal, Decimal]: ...
def __eq__(self, other: object) -> bool: ...
def __floordiv__(self, other: _Decimal) -> Decimal: ...
def __ge__(self, other: _ComparableNum) -> bool: ...
def __gt__(self, other: _ComparableNum) -> bool: ...
def __le__(self, other: _ComparableNum) -> bool: ...
def __lt__(self, other: _ComparableNum) -> bool: ...
def __mod__(self, other: _Decimal) -> Decimal: ...
def __mul__(self, other: _Decimal) -> Decimal: ...
def __neg__(self) -> Decimal: ...
def __pos__(self) -> Decimal: ...
def __pow__(self, other: _Decimal, modulo: Optional[_Decimal] = ...) -> Decimal: ...
def __radd__(self, other: _Decimal) -> Decimal: ...
def __rdivmod__(self, other: _Decimal) -> Tuple[Decimal, Decimal]: ...
def __rfloordiv__(self, other: _Decimal) -> Decimal: ...
def __rmod__(self, other: _Decimal) -> Decimal: ...
def __rmul__(self, other: _Decimal) -> Decimal: ...
def __rsub__(self, other: _Decimal) -> Decimal: ...
def __rtruediv__(self, other: _Decimal) -> Decimal: ...
def __str__(self) -> str: ...
def __sub__(self, other: _Decimal) -> Decimal: ...
def __truediv__(self, other: _Decimal) -> Decimal: ...
else:
def __abs__(self, round: bool = ..., context: Optional[Context] = ...) -> Decimal: ...
def __add__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def __divmod__(self, other: _Decimal, context: Optional[Context] = ...) -> Tuple[Decimal, Decimal]: ...
def __eq__(self, other: object, context: Optional[Context] = ...) -> bool: ...
def __floordiv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def __ge__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ...
def __gt__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ...
def __le__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ...
def __lt__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ...
def __mod__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def __mul__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def __neg__(self, context: Optional[Context] = ...) -> Decimal: ...
def __pos__(self, context: Optional[Context] = ...) -> Decimal: ...
def __pow__(self, other: _Decimal, modulo: Optional[_Decimal] = ..., context: Optional[Context] = ...) -> Decimal: ...
def __radd__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def __rdivmod__(self, other: _Decimal, context: Optional[Context] = ...) -> Tuple[Decimal, Decimal]: ...
def __rfloordiv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def __rmod__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def __rmul__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def __rsub__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def __rtruediv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def __str__(self, eng: bool = ..., context: Optional[Context] = ...) -> str: ...
def __sub__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def __truediv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def __abs__(self) -> Decimal: ...
def __add__(self, other: _Decimal) -> Decimal: ...
def __divmod__(self, other: _Decimal) -> Tuple[Decimal, Decimal]: ...
def __eq__(self, other: object) -> bool: ...
def __floordiv__(self, other: _Decimal) -> Decimal: ...
def __ge__(self, other: _ComparableNum) -> bool: ...
def __gt__(self, other: _ComparableNum) -> bool: ...
def __le__(self, other: _ComparableNum) -> bool: ...
def __lt__(self, other: _ComparableNum) -> bool: ...
def __mod__(self, other: _Decimal) -> Decimal: ...
def __mul__(self, other: _Decimal) -> Decimal: ...
def __neg__(self) -> Decimal: ...
def __pos__(self) -> Decimal: ...
def __pow__(self, other: _Decimal, modulo: Optional[_Decimal] = ...) -> Decimal: ...
def __radd__(self, other: _Decimal) -> Decimal: ...
def __rdivmod__(self, other: _Decimal) -> Tuple[Decimal, Decimal]: ...
def __rfloordiv__(self, other: _Decimal) -> Decimal: ...
def __rmod__(self, other: _Decimal) -> Decimal: ...
def __rmul__(self, other: _Decimal) -> Decimal: ...
def __rsub__(self, other: _Decimal) -> Decimal: ...
def __rtruediv__(self, other: _Decimal) -> Decimal: ...
def __str__(self) -> str: ...
def __sub__(self, other: _Decimal) -> Decimal: ...
def __truediv__(self, other: _Decimal) -> Decimal: ...
def remainder_near(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def __float__(self) -> float: ...
def __int__(self) -> int: ...
@@ -133,26 +90,17 @@ class Decimal(object):
def imag(self) -> Decimal: ...
def conjugate(self) -> Decimal: ...
def __complex__(self) -> complex: ...
if sys.version_info >= (3,):
@overload
def __round__(self) -> int: ...
@overload
def __round__(self, ndigits: int) -> Decimal: ...
def __floor__(self) -> int: ...
def __ceil__(self) -> int: ...
else:
def __long__(self) -> long: ...
@overload
def __round__(self) -> int: ...
@overload
def __round__(self, ndigits: int) -> Decimal: ...
def __floor__(self) -> int: ...
def __ceil__(self) -> int: ...
def fma(self, other: _Decimal, third: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def __rpow__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def normalize(self, context: Optional[Context] = ...) -> Decimal: ...
if sys.version_info >= (3,):
def quantize(self, exp: _Decimal, rounding: Optional[str] = ..., context: Optional[Context] = ...) -> Decimal: ...
def same_quantum(self, other: _Decimal, context: Optional[Context] = ...) -> bool: ...
else:
def quantize(
self, exp: _Decimal, rounding: Optional[str] = ..., context: Optional[Context] = ..., watchexp: bool = ...
) -> Decimal: ...
def same_quantum(self, other: _Decimal) -> bool: ...
def quantize(self, exp: _Decimal, rounding: Optional[str] = ..., context: Optional[Context] = ...) -> Decimal: ...
def same_quantum(self, other: _Decimal, context: Optional[Context] = ...) -> bool: ...
def to_integral_exact(self, rounding: Optional[str] = ..., context: Optional[Context] = ...) -> Decimal: ...
def to_integral_value(self, rounding: Optional[str] = ..., context: Optional[Context] = ...) -> Decimal: ...
def to_integral(self, rounding: Optional[str] = ..., context: Optional[Context] = ...) -> Decimal: ...
@@ -160,23 +108,13 @@ class Decimal(object):
def max(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def min(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def adjusted(self) -> int: ...
if sys.version_info >= (3,):
def canonical(self) -> Decimal: ...
else:
def canonical(self, context: Optional[Context] = ...) -> Decimal: ...
def canonical(self) -> Decimal: ...
def compare_signal(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
if sys.version_info >= (3,):
def compare_total(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def compare_total_mag(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
else:
def compare_total(self, other: _Decimal) -> Decimal: ...
def compare_total_mag(self, other: _Decimal) -> Decimal: ...
def compare_total(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def compare_total_mag(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def copy_abs(self) -> Decimal: ...
def copy_negate(self) -> Decimal: ...
if sys.version_info >= (3,):
def copy_sign(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
else:
def copy_sign(self, other: _Decimal) -> Decimal: ...
def copy_sign(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ...
def exp(self, context: Optional[Context] = ...) -> Decimal: ...
def is_canonical(self) -> bool: ...
def is_finite(self) -> bool: ...
@@ -225,46 +163,27 @@ class Context(object):
Emin: int
Emax: int
capitals: int
if sys.version_info >= (3,):
clamp: int
else:
_clamp: int
clamp: int
traps: Dict[_TrapType, bool]
flags: Dict[_TrapType, bool]
if sys.version_info >= (3,):
def __init__(
self,
prec: Optional[int] = ...,
rounding: Optional[str] = ...,
Emin: Optional[int] = ...,
Emax: Optional[int] = ...,
capitals: Optional[int] = ...,
clamp: Optional[int] = ...,
flags: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ...,
traps: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ...,
_ignored_flags: Optional[List[_TrapType]] = ...,
) -> None: ...
else:
def __init__(
self,
prec: Optional[int] = ...,
rounding: Optional[str] = ...,
traps: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ...,
flags: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ...,
Emin: Optional[int] = ...,
Emax: Optional[int] = ...,
capitals: Optional[int] = ...,
_clamp: Optional[int] = ...,
_ignored_flags: Optional[List[_TrapType]] = ...,
) -> None: ...
if sys.version_info >= (3,):
# __setattr__() only allows to set a specific set of attributes,
# already defined above.
def __delattr__(self, name: str) -> None: ...
def __reduce__(self) -> Tuple[Type[Context], Tuple[Any, ...]]: ...
def __init__(
self,
prec: Optional[int] = ...,
rounding: Optional[str] = ...,
Emin: Optional[int] = ...,
Emax: Optional[int] = ...,
capitals: Optional[int] = ...,
clamp: Optional[int] = ...,
flags: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ...,
traps: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ...,
_ignored_flags: Optional[List[_TrapType]] = ...,
) -> None: ...
# __setattr__() only allows to set a specific set of attributes,
# already defined above.
def __delattr__(self, name: str) -> None: ...
def __reduce__(self) -> Tuple[Type[Context], Tuple[Any, ...]]: ...
def clear_flags(self) -> None: ...
if sys.version_info >= (3,):
def clear_traps(self) -> None: ...
def clear_traps(self) -> None: ...
def copy(self) -> Context: ...
def __copy__(self) -> Context: ...
__hash__: Any = ...