|
1 | 1 | # Stubs for decimal (Python 2)
|
2 |
| -# |
3 |
| -# NOTE: This dynamically typed stub was automatically generated by stubgen. |
4 | 2 |
|
5 |
| -from typing import Any, SupportsAbs, SupportsFloat, SupportsInt |
| 3 | +from typing import Any, Optional, Sequence, Tuple, Union, SupportsAbs, SupportsFloat, SupportsInt |
6 | 4 |
|
7 |
| -ROUND_DOWN = ... # type: Any |
8 |
| -ROUND_HALF_UP = ... # type: Any |
9 |
| -ROUND_HALF_EVEN = ... # type: Any |
10 |
| -ROUND_CEILING = ... # type: Any |
11 |
| -ROUND_FLOOR = ... # type: Any |
12 |
| -ROUND_UP = ... # type: Any |
13 |
| -ROUND_HALF_DOWN = ... # type: Any |
14 |
| -ROUND_05UP = ... # type: Any |
| 5 | +_Decimal = Union[Decimal, int] |
| 6 | + |
| 7 | +DecimalTuple = NamedTuple('DecimalTuple', |
| 8 | + [('sign', int), |
| 9 | + ('digits', Sequence[int]), # TODO: Use Tuple[int, ...] |
| 10 | + ('exponent', int)]) |
| 11 | + |
| 12 | +ROUND_DOWN = ... # type: str |
| 13 | +ROUND_HALF_UP = ... # type: str |
| 14 | +ROUND_HALF_EVEN = ... # type: str |
| 15 | +ROUND_CEILING = ... # type: str |
| 16 | +ROUND_FLOOR = ... # type: str |
| 17 | +ROUND_UP = ... # type: str |
| 18 | +ROUND_HALF_DOWN = ... # type: str |
| 19 | +ROUND_05UP = ... # type: str |
15 | 20 |
|
16 | 21 | class DecimalException(ArithmeticError):
|
17 | 22 | def handle(self, context, *args): ...
|
@@ -40,120 +45,125 @@ class Overflow(Inexact, Rounded): ...
|
40 | 45 |
|
41 | 46 | class Underflow(Inexact, Rounded, Subnormal): ...
|
42 | 47 |
|
43 |
| -def setcontext(context): ... |
44 |
| -def getcontext(): ... |
45 |
| -def localcontext(ctx=None): ... |
| 48 | +def setcontext(context: Context): ... |
| 49 | +def getcontext() -> Context: ... |
| 50 | +def localcontext(ctx: Optional[Context] = None) -> _ContextManager: ... |
46 | 51 |
|
47 | 52 | class Decimal(SupportsAbs[Decimal], SupportsFloat, SupportsInt):
|
48 |
| - def __new__(cls, value=..., context=None): ... |
| 53 | + def __init__(cls, value: Union[_Decimal, float, str, |
| 54 | + Tuple[int, Sequence[int], int]] = ..., |
| 55 | + context: Context = ...) -> None: ... |
49 | 56 | @classmethod
|
50 |
| - def from_float(cls, f): ... |
51 |
| - def __nonzero__(self): ... |
52 |
| - def __eq__(self, other, context=None): ... |
53 |
| - def __ne__(self, other, context=None): ... |
54 |
| - def __lt__(self, other, context=None): ... |
55 |
| - def __le__(self, other, context=None): ... |
56 |
| - def __gt__(self, other, context=None): ... |
57 |
| - def __ge__(self, other, context=None): ... |
58 |
| - def compare(self, other, context=None): ... |
59 |
| - def __hash__(self): ... |
60 |
| - def as_tuple(self): ... |
61 |
| - def to_eng_string(self, context=None): ... |
62 |
| - def __neg__(self, context=None): ... |
63 |
| - def __pos__(self, context=None): ... |
64 |
| - def __abs__(self, round=True, context=None): ... |
65 |
| - def __add__(self, other, context=None): ... |
66 |
| - def __radd__(self, other, context=None): ... |
67 |
| - def __sub__(self, other, context=None): ... |
68 |
| - def __rsub__(self, other, context=None): ... |
69 |
| - def __mul__(self, other, context=None): ... |
70 |
| - def __rmul__(self, other, context=None): ... |
71 |
| - def __truediv__(self, other, context=None): ... |
72 |
| - def __rtruediv__(self, other, context=None): ... |
73 |
| - def __div__(self, other, context=None): ... |
74 |
| - def __rdiv__(self, other, context=None): ... |
75 |
| - def __divmod__(self, other, context=None): ... |
76 |
| - def __rdivmod__(self, other, context=None): ... |
77 |
| - def __mod__(self, other, context=None): ... |
78 |
| - def __rmod__(self, other, context=None): ... |
79 |
| - def remainder_near(self, other, context=None): ... |
80 |
| - def __floordiv__(self, other, context=None): ... |
81 |
| - def __rfloordiv__(self, other, context=None): ... |
82 |
| - def __float__(self): ... |
83 |
| - def __int__(self): ... |
84 |
| - def __trunc__(self): ... |
85 |
| - real = ... # type: property |
86 |
| - imag = ... # type: property |
87 |
| - def conjugate(self): ... |
88 |
| - def __complex__(self): ... |
89 |
| - def __long__(self): ... |
90 |
| - def fma(self, other, third, context=None): ... |
91 |
| - def __pow__(self, other, modulo=None, context=None): ... |
92 |
| - def __rpow__(self, other, context=None): ... |
93 |
| - def normalize(self, context=None): ... |
94 |
| - def quantize(self, exp, rounding=None, context=None, watchexp=True): ... |
95 |
| - def same_quantum(self, other): ... |
96 |
| - def to_integral_exact(self, rounding=None, context=None): ... |
97 |
| - def to_integral_value(self, rounding=None, context=None): ... |
98 |
| - def to_integral(self, rounding=None, context=None): ... |
99 |
| - def sqrt(self, context=None): ... |
100 |
| - def max(self, other, context=None): ... |
101 |
| - def min(self, other, context=None): ... |
102 |
| - def adjusted(self): ... |
103 |
| - def canonical(self, context=None): ... |
104 |
| - def compare_signal(self, other, context=None): ... |
105 |
| - def compare_total(self, other): ... |
106 |
| - def compare_total_mag(self, other): ... |
107 |
| - def copy_abs(self): ... |
108 |
| - def copy_negate(self): ... |
109 |
| - def copy_sign(self, other): ... |
110 |
| - def exp(self, context=None): ... |
111 |
| - def is_canonical(self): ... |
112 |
| - def is_finite(self): ... |
113 |
| - def is_infinite(self): ... |
114 |
| - def is_nan(self): ... |
115 |
| - def is_normal(self, context=None): ... |
116 |
| - def is_qnan(self): ... |
117 |
| - def is_signed(self): ... |
118 |
| - def is_snan(self): ... |
119 |
| - def is_subnormal(self, context=None): ... |
120 |
| - def is_zero(self): ... |
121 |
| - def ln(self, context=None): ... |
122 |
| - def log10(self, context=None): ... |
123 |
| - def logb(self, context=None): ... |
124 |
| - def logical_and(self, other, context=None): ... |
125 |
| - def logical_invert(self, context=None): ... |
126 |
| - def logical_or(self, other, context=None): ... |
127 |
| - def logical_xor(self, other, context=None): ... |
128 |
| - def max_mag(self, other, context=None): ... |
129 |
| - def min_mag(self, other, context=None): ... |
130 |
| - def next_minus(self, context=None): ... |
131 |
| - def next_plus(self, context=None): ... |
132 |
| - def next_toward(self, other, context=None): ... |
133 |
| - def number_class(self, context=None): ... |
134 |
| - def radix(self): ... |
135 |
| - def rotate(self, other, context=None): ... |
136 |
| - def scaleb(self, other, context=None): ... |
137 |
| - def shift(self, other, context=None): ... |
| 57 | + def from_float(cls, f: float) -> Decimal: ... |
| 58 | + def __nonzero__(self) -> bool: ... |
| 59 | + def __eq__(self, other: object) -> bool: ... |
| 60 | + def __ne__(self, other: object) -> bool: ... |
| 61 | + def __lt__(self, other: _Decimal) -> bool: ... |
| 62 | + def __le__(self, other: _Decimal) -> bool: ... |
| 63 | + def __gt__(self, other: _Decimal) -> bool: ... |
| 64 | + def __ge__(self, other: _Decimal) -> bool: ... |
| 65 | + def compare(self, other: _Decimal) -> int: ... |
| 66 | + def __hash__(self) -> int: ... |
| 67 | + def as_tuple(self) -> DecimalTuple: ... |
| 68 | + def to_eng_string(self, context: Context = ...) -> str: ... |
| 69 | + def __neg__(self) -> Decimal: ... |
| 70 | + def __pos__(self) -> Decimal: ... |
| 71 | + def __abs__(self, round: bool = True) -> Decimal: ... |
| 72 | + def __add__(self, other: _Decimal) -> Decimal: ... |
| 73 | + def __radd__(self, other: _Decimal) -> Decimal: ... |
| 74 | + def __sub__(self, other: _Decimal) -> Decimal: ... |
| 75 | + def __rsub__(self, other: _Decimal) -> Decimal: ... |
| 76 | + def __mul__(self, other: _Decimal) -> Decimal: ... |
| 77 | + def __rmul__(self, other: _Decimal) -> Decimal: ... |
| 78 | + def __truediv__(self, other: _Decimal) -> Decimal: ... |
| 79 | + def __rtruediv__(self, other: _Decimal) -> Decimal: ... |
| 80 | + def __div__(self, other: _Decimal) -> Decimal: ... |
| 81 | + def __rdiv__(self, other: _Decimal) -> Decimal: ... |
| 82 | + def __divmod__(self, other: _Decimal) -> Decimal: ... |
| 83 | + def __rdivmod__(self, other: _Decimal) -> Decimal: ... |
| 84 | + def __mod__(self, other: _Decimal) -> Decimal: ... |
| 85 | + def __rmod__(self, other: _Decimal) -> Decimal: ... |
| 86 | + def remainder_near(self, other: _Decimal, context: Context = ...) -> Decimal: ... |
| 87 | + def __floordiv__(self, other: _Decimal) -> Decimal: ... |
| 88 | + def __rfloordiv__(self, other: _Decimal) -> Decimal: ... |
| 89 | + def __float__(self) -> float: ... |
| 90 | + def __int__(self) -> int: ... |
| 91 | + def __trunc__(self) -> int: ... |
| 92 | + @property |
| 93 | + def imag(self) -> Decimal: ... |
| 94 | + @property |
| 95 | + def real(self) -> Decimal: ... |
| 96 | + def conjugate(self) -> Decimal: ... |
| 97 | + def __complex__(self) -> complex: ... |
| 98 | + def __long__(self) -> long: ... |
| 99 | + def fma(self, other: _Decimal, third: _Decimal, context: Context = ...) -> Decimal: ... |
| 100 | + def __pow__(self, other: _Decimal) -> Decimal: ... |
| 101 | + def __rpow__(self, other: int) -> Decimal: ... |
| 102 | + def normalize(self, context: Context = ...) -> Decimal: ... |
| 103 | + def quantize(self, exp: _Decimal, rounding: str = ..., |
| 104 | + context: Context = ...) -> Decimal: ... |
| 105 | + def same_quantum(self, other: Decimal) -> bool: ... |
| 106 | + def to_integral(self, rounding: str = ..., context: Context = ...) -> Decimal: ... |
| 107 | + def to_integral_exact(self, rounding: str = ..., context: Context = ...) -> Decimal: ... |
| 108 | + def to_integral_value(self, rounding: str = ..., context: Context = ...) -> Decimal: ... |
| 109 | + def sqrt(self, context: Context = ...) -> Decimal: ... |
| 110 | + def max(self, other: _Decimal, context: Context = ...) -> Decimal: ... |
| 111 | + def min(self, other: _Decimal, context: Context = ...) -> Decimal: ... |
| 112 | + def adjusted(self) -> int: ... |
| 113 | + def canonical(self, context: Context = ...) -> Decimal: ... |
| 114 | + def compare_signal(self, other: _Decimal, context: Context = ...) -> Decimal: ... |
| 115 | + def compare_total(self, other: _Decimal) -> Decimal: ... |
| 116 | + def compare_total_mag(self, other: _Decimal) -> Decimal: ... |
| 117 | + def copy_abs(self) -> Decimal: ... |
| 118 | + def copy_negate(self) -> Decimal: ... |
| 119 | + def copy_sign(self, other: _Decimal) -> Decimal: ... |
| 120 | + def exp(self, context: Context = ...) -> Decimal: ... |
| 121 | + def is_canonical(self) -> bool: ... |
| 122 | + def is_finite(self) -> bool: ... |
| 123 | + def is_infinite(self) -> bool: ... |
| 124 | + def is_nan(self) -> bool: ... |
| 125 | + def is_normal(self, context: Context = ...) -> bool: ... |
| 126 | + def is_qnan(self) -> bool: ... |
| 127 | + def is_signed(self) -> bool: ... |
| 128 | + def is_snan(self) -> bool: ... |
| 129 | + def is_subnormal(self, context: Context = ...) -> bool: ... |
| 130 | + def is_zero(self) -> bool: ... |
| 131 | + def ln(self, context: Context = ...) -> Decimal: ... |
| 132 | + def log10(self, context: Context = ...) -> Decimal: ... |
| 133 | + def logb(self, context: Context = ...) -> Decimal: ... |
| 134 | + def logical_and(self, other: _Decimal, context: Context = ...) -> Decimal: ... |
| 135 | + def logical_invert(self, context: Context = ...) -> Decimal: ... |
| 136 | + def logical_or(self, other: _Decimal, context: Context = ...) -> Decimal: ... |
| 137 | + def logical_xor(self, other: _Decimal, context: Context = ...) -> Decimal: ... |
| 138 | + def max_mag(self, other: _Decimal, context: Context = ...) -> Decimal: ... |
| 139 | + def min_mag(self, other: _Decimal, context: Context = ...) -> Decimal: ... |
| 140 | + def next_minus(self, context: Context = ...) -> Decimal: ... |
| 141 | + def next_plus(self, context: Context = ...) -> Decimal: ... |
| 142 | + def next_toward(self, other: _Decimal, context: Context = ...) -> Decimal: ... |
| 143 | + def number_class(self, context: Context = ...) -> str: ... |
| 144 | + def radix(self) -> Decimal: ... |
| 145 | + def rotate(self, other: _Decimal, context: Context = ...) -> Decimal: ... |
| 146 | + def scaleb(self, other: _Decimal, context: Context = ...) -> Decimal: ... |
| 147 | + def shift(self, other: _Decimal, context: Context = ...) -> Decimal: ... |
138 | 148 | def __reduce__(self): ...
|
139 | 149 | def __copy__(self): ...
|
140 | 150 | def __deepcopy__(self, memo): ...
|
141 |
| - def __format__(self, specifier, context=None, _localeconv=None): ... |
| 151 | + def __format__(self, specifier, context=None, _localeconv=None) -> str: ... |
142 | 152 |
|
143 | 153 | class _ContextManager:
|
144 |
| - new_context = ... # type: Any |
145 |
| - def __init__(self, new_context): ... |
146 |
| - saved_context = ... # type: Any |
| 154 | + new_context = ... # type: Context |
| 155 | + saved_context = ... # type: Context |
| 156 | + def __init__(self, new_context: Context) -> None: ... |
147 | 157 | def __enter__(self): ...
|
148 | 158 | def __exit__(self, t, v, tb): ...
|
149 | 159 |
|
150 | 160 | class Context:
|
151 |
| - prec = ... # type: Any |
152 |
| - rounding = ... # type: Any |
153 |
| - Emin = ... # type: Any |
154 |
| - Emax = ... # type: Any |
155 |
| - capitals = ... # type: Any |
156 |
| - traps = ... # type: Any |
| 161 | + prec = ... # type: int |
| 162 | + rounding = ... # type: str |
| 163 | + Emin = ... # type: int |
| 164 | + Emax = ... # type: int |
| 165 | + capitals = ... # type: int |
| 166 | + traps = ... # type: Dict[type, bool] |
157 | 167 | flags = ... # type: Any
|
158 | 168 | def __init__(self, prec=None, rounding=None, traps=None, flags=None, Emin=None, Emax=None, capitals=None, _clamp=0, _ignored_flags=None): ...
|
159 | 169 | def clear_flags(self): ...
|
@@ -226,6 +236,6 @@ class Context:
|
226 | 236 | def to_integral_value(self, a): ...
|
227 | 237 | def to_integral(self, a): ...
|
228 | 238 |
|
229 |
| -DefaultContext = ... # type: Any |
230 |
| -BasicContext = ... # type: Any |
231 |
| -ExtendedContext = ... # type: Any |
| 239 | +DefaultContext = ... # type: Context |
| 240 | +BasicContext = ... # type: Context |
| 241 | +ExtendedContext = ... # type: Context |
0 commit comments