mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-23 19:41:51 +08:00
Use PEP 585 syntax in Python 2, protobuf & _ast stubs, where possible (#6949)
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
from types import TracebackType
|
||||
from typing import Any, Container, Dict, List, NamedTuple, Sequence, Text, Tuple, Type, TypeVar, Union
|
||||
from typing import Any, Container, NamedTuple, Sequence, Text, TypeVar, Union
|
||||
|
||||
_Decimal = Union[Decimal, int]
|
||||
_DecimalNew = Union[Decimal, float, Text, Tuple[int, Sequence[int], int]]
|
||||
_DecimalNew = Union[Decimal, float, Text, tuple[int, Sequence[int], int]]
|
||||
_ComparableNum = Union[Decimal, float]
|
||||
_DecimalT = TypeVar("_DecimalT", bound=Decimal)
|
||||
|
||||
class DecimalTuple(NamedTuple):
|
||||
sign: int
|
||||
digits: Tuple[int, ...]
|
||||
digits: tuple[int, ...]
|
||||
exponent: int
|
||||
|
||||
ROUND_DOWN: str
|
||||
@@ -41,7 +41,7 @@ def getcontext() -> Context: ...
|
||||
def localcontext(ctx: Context | None = ...) -> _ContextManager: ...
|
||||
|
||||
class Decimal(object):
|
||||
def __new__(cls: Type[_DecimalT], value: _DecimalNew = ..., context: Context | None = ...) -> _DecimalT: ...
|
||||
def __new__(cls: type[_DecimalT], value: _DecimalNew = ..., context: Context | None = ...) -> _DecimalT: ...
|
||||
@classmethod
|
||||
def from_float(cls, __f: float) -> Decimal: ...
|
||||
def __nonzero__(self) -> bool: ...
|
||||
@@ -54,7 +54,7 @@ class Decimal(object):
|
||||
def to_eng_string(self, context: Context | None = ...) -> str: ...
|
||||
def __abs__(self, round: bool = ..., context: Context | None = ...) -> Decimal: ...
|
||||
def __add__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ...
|
||||
def __divmod__(self, other: _Decimal, context: Context | None = ...) -> Tuple[Decimal, Decimal]: ...
|
||||
def __divmod__(self, other: _Decimal, context: Context | None = ...) -> tuple[Decimal, Decimal]: ...
|
||||
def __eq__(self, other: object, context: Context | None = ...) -> bool: ...
|
||||
def __floordiv__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ...
|
||||
def __ge__(self, other: _ComparableNum, context: Context | None = ...) -> bool: ...
|
||||
@@ -67,7 +67,7 @@ class Decimal(object):
|
||||
def __pos__(self, context: Context | None = ...) -> Decimal: ...
|
||||
def __pow__(self, other: _Decimal, modulo: _Decimal | None = ..., context: Context | None = ...) -> Decimal: ...
|
||||
def __radd__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ...
|
||||
def __rdivmod__(self, other: _Decimal, context: Context | None = ...) -> Tuple[Decimal, Decimal]: ...
|
||||
def __rdivmod__(self, other: _Decimal, context: Context | None = ...) -> tuple[Decimal, Decimal]: ...
|
||||
def __rfloordiv__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ...
|
||||
def __rmod__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ...
|
||||
def __rmul__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ...
|
||||
@@ -136,7 +136,7 @@ class Decimal(object):
|
||||
def rotate(self, other: _Decimal, context: Context | None = ...) -> Decimal: ...
|
||||
def scaleb(self, other: _Decimal, context: Context | None = ...) -> Decimal: ...
|
||||
def shift(self, other: _Decimal, context: Context | None = ...) -> Decimal: ...
|
||||
def __reduce__(self) -> Tuple[Type[Decimal], Tuple[str]]: ...
|
||||
def __reduce__(self) -> tuple[type[Decimal], tuple[str]]: ...
|
||||
def __copy__(self) -> Decimal: ...
|
||||
def __deepcopy__(self, memo: Any) -> Decimal: ...
|
||||
def __format__(self, specifier: str, context: Context | None = ...) -> str: ...
|
||||
@@ -146,9 +146,9 @@ class _ContextManager(object):
|
||||
saved_context: Context
|
||||
def __init__(self, new_context: Context) -> None: ...
|
||||
def __enter__(self) -> Context: ...
|
||||
def __exit__(self, t: Type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ...
|
||||
def __exit__(self, t: type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ...
|
||||
|
||||
_TrapType = Type[DecimalException]
|
||||
_TrapType = type[DecimalException]
|
||||
|
||||
class Context(object):
|
||||
prec: int
|
||||
@@ -157,19 +157,19 @@ class Context(object):
|
||||
Emax: int
|
||||
capitals: int
|
||||
_clamp: int
|
||||
traps: Dict[_TrapType, bool]
|
||||
flags: Dict[_TrapType, bool]
|
||||
traps: dict[_TrapType, bool]
|
||||
flags: dict[_TrapType, bool]
|
||||
def __init__(
|
||||
self,
|
||||
prec: int | None = ...,
|
||||
rounding: str | None = ...,
|
||||
traps: None | Dict[_TrapType, bool] | Container[_TrapType] = ...,
|
||||
flags: None | Dict[_TrapType, bool] | Container[_TrapType] = ...,
|
||||
traps: None | dict[_TrapType, bool] | Container[_TrapType] = ...,
|
||||
flags: None | dict[_TrapType, bool] | Container[_TrapType] = ...,
|
||||
Emin: int | None = ...,
|
||||
Emax: int | None = ...,
|
||||
capitals: int | None = ...,
|
||||
_clamp: int | None = ...,
|
||||
_ignored_flags: List[_TrapType] | None = ...,
|
||||
_ignored_flags: list[_TrapType] | None = ...,
|
||||
) -> None: ...
|
||||
def clear_flags(self) -> None: ...
|
||||
def copy(self) -> Context: ...
|
||||
@@ -192,7 +192,7 @@ class Context(object):
|
||||
def copy_sign(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
|
||||
def divide(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
|
||||
def divide_int(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
|
||||
def divmod(self, __x: _Decimal, __y: _Decimal) -> Tuple[Decimal, Decimal]: ...
|
||||
def divmod(self, __x: _Decimal, __y: _Decimal) -> tuple[Decimal, Decimal]: ...
|
||||
def exp(self, __x: _Decimal) -> Decimal: ...
|
||||
def fma(self, __x: _Decimal, __y: _Decimal, __z: _Decimal) -> Decimal: ...
|
||||
def is_canonical(self, __x: _Decimal) -> bool: ...
|
||||
|
||||
Reference in New Issue
Block a user