basedpyright 1.12.6 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/pyright-langserver.js +1 -1
  2. package/dist/pyright-langserver.js.map +1 -1
  3. package/dist/pyright.js +1 -1
  4. package/dist/pyright.js.map +1 -1
  5. package/dist/typeshed-fallback/stdlib/_ast.pyi +279 -42
  6. package/dist/typeshed-fallback/stdlib/_bisect.pyi +149 -12
  7. package/dist/typeshed-fallback/stdlib/_codecs.pyi +125 -14
  8. package/dist/typeshed-fallback/stdlib/_csv.pyi +130 -7
  9. package/dist/typeshed-fallback/stdlib/_ctypes.pyi +72 -17
  10. package/dist/typeshed-fallback/stdlib/_curses.pyi +626 -78
  11. package/dist/typeshed-fallback/stdlib/_decimal.pyi +775 -153
  12. package/dist/typeshed-fallback/stdlib/_heapq.pyi +61 -5
  13. package/dist/typeshed-fallback/stdlib/_imp.pyi +70 -15
  14. package/dist/typeshed-fallback/stdlib/_json.pyi +55 -12
  15. package/dist/typeshed-fallback/stdlib/_locale.pyi +63 -12
  16. package/dist/typeshed-fallback/stdlib/_lsprof.pyi +61 -4
  17. package/dist/typeshed-fallback/stdlib/_operator.pyi +238 -62
  18. package/dist/typeshed-fallback/stdlib/_posixsubprocess.pyi +25 -1
  19. package/dist/typeshed-fallback/stdlib/_random.pyi +23 -5
  20. package/dist/typeshed-fallback/stdlib/_socket.pyi +618 -63
  21. package/dist/typeshed-fallback/stdlib/_stat.pyi +140 -13
  22. package/dist/typeshed-fallback/stdlib/_thread.pyi +215 -22
  23. package/dist/typeshed-fallback/stdlib/_tkinter.pyi +44 -11
  24. package/dist/typeshed-fallback/stdlib/_tracemalloc.pyi +71 -10
  25. package/dist/typeshed-fallback/stdlib/_warnings.pyi +53 -6
  26. package/dist/typeshed-fallback/stdlib/_weakref.pyi +43 -10
  27. package/dist/typeshed-fallback/stdlib/_winapi.pyi +255 -255
  28. package/dist/typeshed-fallback/stdlib/array.pyi +233 -44
  29. package/dist/typeshed-fallback/stdlib/atexit.pyi +50 -5
  30. package/dist/typeshed-fallback/stdlib/audioop.pyi +78 -26
  31. package/dist/typeshed-fallback/stdlib/binascii.pyi +105 -18
  32. package/dist/typeshed-fallback/stdlib/builtins.pyi +5254 -829
  33. package/dist/typeshed-fallback/stdlib/cmath.pyi +99 -23
  34. package/dist/typeshed-fallback/stdlib/errno.pyi +15 -0
  35. package/dist/typeshed-fallback/stdlib/faulthandler.pyi +33 -8
  36. package/dist/typeshed-fallback/stdlib/fcntl.pyi +199 -8
  37. package/dist/typeshed-fallback/stdlib/gc.pyi +130 -18
  38. package/dist/typeshed-fallback/stdlib/grp.pyi +58 -7
  39. package/dist/typeshed-fallback/stdlib/itertools.pyi +281 -42
  40. package/dist/typeshed-fallback/stdlib/marshal.pyi +82 -4
  41. package/dist/typeshed-fallback/stdlib/math.pyi +357 -61
  42. package/dist/typeshed-fallback/stdlib/mmap.pyi +47 -8
  43. package/dist/typeshed-fallback/stdlib/msvcrt.pyi +32 -32
  44. package/dist/typeshed-fallback/stdlib/nt.pyi +118 -111
  45. package/dist/typeshed-fallback/stdlib/parser.pyi +55 -24
  46. package/dist/typeshed-fallback/stdlib/posix.pyi +7 -0
  47. package/dist/typeshed-fallback/stdlib/pwd.pyi +60 -10
  48. package/dist/typeshed-fallback/stdlib/pyexpat/__init__.pyi +61 -12
  49. package/dist/typeshed-fallback/stdlib/readline.pyi +184 -27
  50. package/dist/typeshed-fallback/stdlib/resource.pyi +56 -16
  51. package/dist/typeshed-fallback/stdlib/select.pyi +97 -5
  52. package/dist/typeshed-fallback/stdlib/spwd.pyi +60 -11
  53. package/dist/typeshed-fallback/stdlib/sys/__init__.pyi +386 -48
  54. package/dist/typeshed-fallback/stdlib/syslog.pyi +27 -7
  55. package/dist/typeshed-fallback/stdlib/termios.pyi +88 -8
  56. package/dist/typeshed-fallback/stdlib/time.pyi +314 -37
  57. package/dist/typeshed-fallback/stdlib/unicodedata.pyi +264 -34
  58. package/dist/typeshed-fallback/stdlib/winreg.pyi +172 -132
  59. package/dist/typeshed-fallback/stdlib/zlib.pyi +108 -7
  60. package/package.json +1 -1
@@ -1,3 +1,5 @@
1
+ """C decimal arithmetic module"""
2
+
1
3
  import numbers
2
4
  import sys
3
5
  from collections.abc import Container, Sequence
@@ -13,6 +15,7 @@ __version__: Final[str]
13
15
  __libmpdec_version__: Final[str]
14
16
 
15
17
  class DecimalTuple(NamedTuple):
18
+ """DecimalTuple(sign, digits, exponent)"""
16
19
  sign: int
17
20
  digits: tuple[int, ...]
18
21
  exponent: int | Literal["n", "N", "F"]
@@ -47,8 +50,12 @@ class Overflow(Inexact, Rounded): ...
47
50
  class Underflow(Inexact, Rounded, Subnormal): ...
48
51
  class FloatOperation(DecimalException, TypeError): ...
49
52
 
50
- def setcontext(context: Context, /) -> None: ...
51
- def getcontext() -> Context: ...
53
+ def setcontext(context: Context, /) -> None:
54
+ """Set a new default context."""
55
+ ...
56
+ def getcontext() -> Context:
57
+ """Get the current default context."""
58
+ ...
52
59
 
53
60
  if sys.version_info >= (3, 11):
54
61
  def localcontext(
@@ -62,53 +69,182 @@ if sys.version_info >= (3, 11):
62
69
  clamp: int | None = ...,
63
70
  traps: dict[_TrapType, bool] | None = ...,
64
71
  flags: dict[_TrapType, bool] | None = ...,
65
- ) -> _ContextManager: ...
72
+ ) -> _ContextManager:
73
+ """
74
+ Return a context manager that will set the default context to a copy of ctx
75
+ on entry to the with-statement and restore the previous default context when
76
+ exiting the with-statement. If no context is specified, a copy of the current
77
+ default context is used.
78
+ """
79
+ ...
66
80
 
67
81
  else:
68
- def localcontext(ctx: Context | None = None) -> _ContextManager: ...
82
+ def localcontext(ctx: Context | None = None) -> _ContextManager:
83
+ """
84
+ Return a context manager that will set the default context to a copy of ctx
85
+ on entry to the with-statement and restore the previous default context when
86
+ exiting the with-statement. If no context is specified, a copy of the current
87
+ default context is used.
88
+ """
89
+ ...
69
90
 
70
91
  class Decimal:
92
+ """
93
+ Construct a new Decimal object. 'value' can be an integer, string, tuple,
94
+ or another Decimal object. If no value is given, return Decimal('0'). The
95
+ context does not affect the conversion and is only passed to determine if
96
+ the InvalidOperation trap is active.
97
+ """
71
98
  def __new__(cls, value: _DecimalNew = ..., context: Context | None = ...) -> Self: ...
72
99
  @classmethod
73
- def from_float(cls, f: float, /) -> Self: ...
74
- def __bool__(self) -> bool: ...
75
- def compare(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
76
- def __hash__(self) -> int: ...
77
- def as_tuple(self) -> DecimalTuple: ...
78
- def as_integer_ratio(self) -> tuple[int, int]: ...
79
- def to_eng_string(self, context: Context | None = None) -> str: ...
80
- def __abs__(self) -> Decimal: ...
81
- def __add__(self, value: _Decimal, /) -> Decimal: ...
82
- def __divmod__(self, value: _Decimal, /) -> tuple[Decimal, Decimal]: ...
83
- def __eq__(self, value: object, /) -> bool: ...
84
- def __floordiv__(self, value: _Decimal, /) -> Decimal: ...
85
- def __ge__(self, value: _ComparableNum, /) -> bool: ...
86
- def __gt__(self, value: _ComparableNum, /) -> bool: ...
87
- def __le__(self, value: _ComparableNum, /) -> bool: ...
88
- def __lt__(self, value: _ComparableNum, /) -> bool: ...
89
- def __mod__(self, value: _Decimal, /) -> Decimal: ...
90
- def __mul__(self, value: _Decimal, /) -> Decimal: ...
91
- def __neg__(self) -> Decimal: ...
92
- def __pos__(self) -> Decimal: ...
93
- def __pow__(self, value: _Decimal, mod: _Decimal | None = None, /) -> Decimal: ...
94
- def __radd__(self, value: _Decimal, /) -> Decimal: ...
95
- def __rdivmod__(self, value: _Decimal, /) -> tuple[Decimal, Decimal]: ...
96
- def __rfloordiv__(self, value: _Decimal, /) -> Decimal: ...
97
- def __rmod__(self, value: _Decimal, /) -> Decimal: ...
98
- def __rmul__(self, value: _Decimal, /) -> Decimal: ...
99
- def __rsub__(self, value: _Decimal, /) -> Decimal: ...
100
- def __rtruediv__(self, value: _Decimal, /) -> Decimal: ...
101
- def __sub__(self, value: _Decimal, /) -> Decimal: ...
102
- def __truediv__(self, value: _Decimal, /) -> Decimal: ...
103
- def remainder_near(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
104
- def __float__(self) -> float: ...
105
- def __int__(self) -> int: ...
100
+ def from_float(cls, f: float, /) -> Self:
101
+ """
102
+ Class method that converts a float to a decimal number, exactly.
103
+ Since 0.1 is not exactly representable in binary floating point,
104
+ Decimal.from_float(0.1) is not the same as Decimal('0.1').
105
+
106
+ >>> Decimal.from_float(0.1)
107
+ Decimal('0.1000000000000000055511151231257827021181583404541015625')
108
+ >>> Decimal.from_float(float('nan'))
109
+ Decimal('NaN')
110
+ >>> Decimal.from_float(float('inf'))
111
+ Decimal('Infinity')
112
+ >>> Decimal.from_float(float('-inf'))
113
+ Decimal('-Infinity')
114
+ """
115
+ ...
116
+ def __bool__(self) -> bool:
117
+ """self != 0"""
118
+ ...
119
+ def compare(self, other: _Decimal, context: Context | None = None) -> Decimal:
120
+ """
121
+ Compare self to other. Return a decimal value:
122
+
123
+ a or b is a NaN ==> Decimal('NaN')
124
+ a < b ==> Decimal('-1')
125
+ a == b ==> Decimal('0')
126
+ a > b ==> Decimal('1')
127
+ """
128
+ ...
129
+ def __hash__(self) -> int:
130
+ """Return hash(self)."""
131
+ ...
132
+ def as_tuple(self) -> DecimalTuple:
133
+ """Return a tuple representation of the number."""
134
+ ...
135
+ def as_integer_ratio(self) -> tuple[int, int]:
136
+ """
137
+ Decimal.as_integer_ratio() -> (int, int)
138
+
139
+ Return a pair of integers, whose ratio is exactly equal to the original
140
+ Decimal and with a positive denominator. The ratio is in lowest terms.
141
+ Raise OverflowError on infinities and a ValueError on NaNs.
142
+ """
143
+ ...
144
+ def to_eng_string(self, context: Context | None = None) -> str:
145
+ """
146
+ Convert to an engineering-type string. Engineering notation has an exponent
147
+ which is a multiple of 3, so there are up to 3 digits left of the decimal
148
+ place. For example, Decimal('123E+1') is converted to Decimal('1.23E+3').
149
+
150
+ The value of context.capitals determines whether the exponent sign is lower
151
+ or upper case. Otherwise, the context does not affect the operation.
152
+ """
153
+ ...
154
+ def __abs__(self) -> Decimal:
155
+ """abs(self)"""
156
+ ...
157
+ def __add__(self, value: _Decimal, /) -> Decimal:
158
+ """Return self+value."""
159
+ ...
160
+ def __divmod__(self, value: _Decimal, /) -> tuple[Decimal, Decimal]:
161
+ """Return divmod(self, value)."""
162
+ ...
163
+ def __eq__(self, value: object, /) -> bool:
164
+ """Return self==value."""
165
+ ...
166
+ def __floordiv__(self, value: _Decimal, /) -> Decimal:
167
+ """Return self//value."""
168
+ ...
169
+ def __ge__(self, value: _ComparableNum, /) -> bool:
170
+ """Return self>=value."""
171
+ ...
172
+ def __gt__(self, value: _ComparableNum, /) -> bool:
173
+ """Return self>value."""
174
+ ...
175
+ def __le__(self, value: _ComparableNum, /) -> bool:
176
+ """Return self<=value."""
177
+ ...
178
+ def __lt__(self, value: _ComparableNum, /) -> bool:
179
+ """Return self<value."""
180
+ ...
181
+ def __mod__(self, value: _Decimal, /) -> Decimal:
182
+ """Return self%value."""
183
+ ...
184
+ def __mul__(self, value: _Decimal, /) -> Decimal:
185
+ """Return self*value."""
186
+ ...
187
+ def __neg__(self) -> Decimal:
188
+ """-self"""
189
+ ...
190
+ def __pos__(self) -> Decimal:
191
+ """+self"""
192
+ ...
193
+ def __pow__(self, value: _Decimal, mod: _Decimal | None = None, /) -> Decimal:
194
+ """Return pow(self, value, mod)."""
195
+ ...
196
+ def __radd__(self, value: _Decimal, /) -> Decimal:
197
+ """Return value+self."""
198
+ ...
199
+ def __rdivmod__(self, value: _Decimal, /) -> tuple[Decimal, Decimal]:
200
+ """Return divmod(value, self)."""
201
+ ...
202
+ def __rfloordiv__(self, value: _Decimal, /) -> Decimal:
203
+ """Return value//self."""
204
+ ...
205
+ def __rmod__(self, value: _Decimal, /) -> Decimal:
206
+ """Return value%self."""
207
+ ...
208
+ def __rmul__(self, value: _Decimal, /) -> Decimal:
209
+ """Return value*self."""
210
+ ...
211
+ def __rsub__(self, value: _Decimal, /) -> Decimal:
212
+ """Return value-self."""
213
+ ...
214
+ def __rtruediv__(self, value: _Decimal, /) -> Decimal:
215
+ """Return value/self."""
216
+ ...
217
+ def __sub__(self, value: _Decimal, /) -> Decimal:
218
+ """Return self-value."""
219
+ ...
220
+ def __truediv__(self, value: _Decimal, /) -> Decimal:
221
+ """Return self/value."""
222
+ ...
223
+ def remainder_near(self, other: _Decimal, context: Context | None = None) -> Decimal:
224
+ """
225
+ Return the remainder from dividing self by other. This differs from
226
+ self % other in that the sign of the remainder is chosen so as to minimize
227
+ its absolute value. More precisely, the return value is self - n * other
228
+ where n is the integer nearest to the exact value of self / other, and
229
+ if two integers are equally near then the even one is chosen.
230
+
231
+ If the result is zero then its sign will be the sign of self.
232
+ """
233
+ ...
234
+ def __float__(self) -> float:
235
+ """float(self)"""
236
+ ...
237
+ def __int__(self) -> int:
238
+ """int(self)"""
239
+ ...
106
240
  def __trunc__(self) -> int: ...
107
241
  @property
108
242
  def real(self) -> Decimal: ...
109
243
  @property
110
244
  def imag(self) -> Decimal: ...
111
- def conjugate(self) -> Decimal: ...
245
+ def conjugate(self) -> Decimal:
246
+ """Return self."""
247
+ ...
112
248
  def __complex__(self) -> complex: ...
113
249
  @overload
114
250
  def __round__(self) -> int: ...
@@ -116,53 +252,353 @@ class Decimal:
116
252
  def __round__(self, ndigits: int, /) -> Decimal: ...
117
253
  def __floor__(self) -> int: ...
118
254
  def __ceil__(self) -> int: ...
119
- def fma(self, other: _Decimal, third: _Decimal, context: Context | None = None) -> Decimal: ...
120
- def __rpow__(self, value: _Decimal, mod: Context | None = None, /) -> Decimal: ...
121
- def normalize(self, context: Context | None = None) -> Decimal: ...
122
- def quantize(self, exp: _Decimal, rounding: str | None = None, context: Context | None = None) -> Decimal: ...
123
- def same_quantum(self, other: _Decimal, context: Context | None = None) -> bool: ...
124
- def to_integral_exact(self, rounding: str | None = None, context: Context | None = None) -> Decimal: ...
125
- def to_integral_value(self, rounding: str | None = None, context: Context | None = None) -> Decimal: ...
126
- def to_integral(self, rounding: str | None = None, context: Context | None = None) -> Decimal: ...
127
- def sqrt(self, context: Context | None = None) -> Decimal: ...
128
- def max(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
129
- def min(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
130
- def adjusted(self) -> int: ...
131
- def canonical(self) -> Decimal: ...
132
- def compare_signal(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
133
- def compare_total(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
134
- def compare_total_mag(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
135
- def copy_abs(self) -> Decimal: ...
136
- def copy_negate(self) -> Decimal: ...
137
- def copy_sign(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
138
- def exp(self, context: Context | None = None) -> Decimal: ...
139
- def is_canonical(self) -> bool: ...
140
- def is_finite(self) -> bool: ...
141
- def is_infinite(self) -> bool: ...
142
- def is_nan(self) -> bool: ...
143
- def is_normal(self, context: Context | None = None) -> bool: ...
144
- def is_qnan(self) -> bool: ...
145
- def is_signed(self) -> bool: ...
146
- def is_snan(self) -> bool: ...
147
- def is_subnormal(self, context: Context | None = None) -> bool: ...
148
- def is_zero(self) -> bool: ...
149
- def ln(self, context: Context | None = None) -> Decimal: ...
150
- def log10(self, context: Context | None = None) -> Decimal: ...
151
- def logb(self, context: Context | None = None) -> Decimal: ...
152
- def logical_and(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
153
- def logical_invert(self, context: Context | None = None) -> Decimal: ...
154
- def logical_or(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
155
- def logical_xor(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
156
- def max_mag(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
157
- def min_mag(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
158
- def next_minus(self, context: Context | None = None) -> Decimal: ...
159
- def next_plus(self, context: Context | None = None) -> Decimal: ...
160
- def next_toward(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
161
- def number_class(self, context: Context | None = None) -> str: ...
162
- def radix(self) -> Decimal: ...
163
- def rotate(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
164
- def scaleb(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
165
- def shift(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
255
+ def fma(self, other: _Decimal, third: _Decimal, context: Context | None = None) -> Decimal:
256
+ """
257
+ Fused multiply-add. Return self*other+third with no rounding of the
258
+ intermediate product self*other.
259
+
260
+ >>> Decimal(2).fma(3, 5)
261
+ Decimal('11')
262
+ """
263
+ ...
264
+ def __rpow__(self, value: _Decimal, mod: Context | None = None, /) -> Decimal:
265
+ """Return pow(value, self, mod)."""
266
+ ...
267
+ def normalize(self, context: Context | None = None) -> Decimal:
268
+ """
269
+ Normalize the number by stripping the rightmost trailing zeros and
270
+ converting any result equal to Decimal('0') to Decimal('0e0'). Used
271
+ for producing canonical values for members of an equivalence class.
272
+ For example, Decimal('32.100') and Decimal('0.321000e+2') both normalize
273
+ to the equivalent value Decimal('32.1').
274
+ """
275
+ ...
276
+ def quantize(self, exp: _Decimal, rounding: str | None = None, context: Context | None = None) -> Decimal:
277
+ """
278
+ Return a value equal to the first operand after rounding and having the
279
+ exponent of the second operand.
280
+
281
+ >>> Decimal('1.41421356').quantize(Decimal('1.000'))
282
+ Decimal('1.414')
283
+
284
+ Unlike other operations, if the length of the coefficient after the quantize
285
+ operation would be greater than precision, then an InvalidOperation is signaled.
286
+ This guarantees that, unless there is an error condition, the quantized exponent
287
+ is always equal to that of the right-hand operand.
288
+
289
+ Also unlike other operations, quantize never signals Underflow, even if the
290
+ result is subnormal and inexact.
291
+
292
+ If the exponent of the second operand is larger than that of the first, then
293
+ rounding may be necessary. In this case, the rounding mode is determined by the
294
+ rounding argument if given, else by the given context argument; if neither
295
+ argument is given, the rounding mode of the current thread's context is used.
296
+ """
297
+ ...
298
+ def same_quantum(self, other: _Decimal, context: Context | None = None) -> bool:
299
+ """
300
+ Test whether self and other have the same exponent or whether both are NaN.
301
+
302
+ This operation is unaffected by context and is quiet: no flags are changed
303
+ and no rounding is performed. As an exception, the C version may raise
304
+ InvalidOperation if the second operand cannot be converted exactly.
305
+ """
306
+ ...
307
+ def to_integral_exact(self, rounding: str | None = None, context: Context | None = None) -> Decimal:
308
+ """
309
+ Round to the nearest integer, signaling Inexact or Rounded as appropriate if
310
+ rounding occurs. The rounding mode is determined by the rounding parameter
311
+ if given, else by the given context. If neither parameter is given, then the
312
+ rounding mode of the current default context is used.
313
+ """
314
+ ...
315
+ def to_integral_value(self, rounding: str | None = None, context: Context | None = None) -> Decimal:
316
+ """
317
+ Round to the nearest integer without signaling Inexact or Rounded. The
318
+ rounding mode is determined by the rounding parameter if given, else by
319
+ the given context. If neither parameter is given, then the rounding mode
320
+ of the current default context is used.
321
+ """
322
+ ...
323
+ def to_integral(self, rounding: str | None = None, context: Context | None = None) -> Decimal:
324
+ """
325
+ Identical to the to_integral_value() method. The to_integral() name has been
326
+ kept for compatibility with older versions.
327
+ """
328
+ ...
329
+ def sqrt(self, context: Context | None = None) -> Decimal:
330
+ """
331
+ Return the square root of the argument to full precision. The result is
332
+ correctly rounded using the ROUND_HALF_EVEN rounding mode.
333
+ """
334
+ ...
335
+ def max(self, other: _Decimal, context: Context | None = None) -> Decimal:
336
+ """
337
+ Maximum of self and other. If one operand is a quiet NaN and the other is
338
+ numeric, the numeric operand is returned.
339
+ """
340
+ ...
341
+ def min(self, other: _Decimal, context: Context | None = None) -> Decimal:
342
+ """
343
+ Minimum of self and other. If one operand is a quiet NaN and the other is
344
+ numeric, the numeric operand is returned.
345
+ """
346
+ ...
347
+ def adjusted(self) -> int:
348
+ """Return the adjusted exponent of the number. Defined as exp + digits - 1."""
349
+ ...
350
+ def canonical(self) -> Decimal:
351
+ """
352
+ Return the canonical encoding of the argument. Currently, the encoding
353
+ of a Decimal instance is always canonical, so this operation returns its
354
+ argument unchanged.
355
+ """
356
+ ...
357
+ def compare_signal(self, other: _Decimal, context: Context | None = None) -> Decimal:
358
+ """Identical to compare, except that all NaNs signal."""
359
+ ...
360
+ def compare_total(self, other: _Decimal, context: Context | None = None) -> Decimal:
361
+ """
362
+ Compare two operands using their abstract representation rather than
363
+ their numerical value. Similar to the compare() method, but the result
364
+ gives a total ordering on Decimal instances. Two Decimal instances with
365
+ the same numeric value but different representations compare unequal
366
+ in this ordering:
367
+
368
+ >>> Decimal('12.0').compare_total(Decimal('12'))
369
+ Decimal('-1')
370
+
371
+ Quiet and signaling NaNs are also included in the total ordering. The result
372
+ of this function is Decimal('0') if both operands have the same representation,
373
+ Decimal('-1') if the first operand is lower in the total order than the second,
374
+ and Decimal('1') if the first operand is higher in the total order than the
375
+ second operand. See the specification for details of the total order.
376
+
377
+ This operation is unaffected by context and is quiet: no flags are changed
378
+ and no rounding is performed. As an exception, the C version may raise
379
+ InvalidOperation if the second operand cannot be converted exactly.
380
+ """
381
+ ...
382
+ def compare_total_mag(self, other: _Decimal, context: Context | None = None) -> Decimal:
383
+ """
384
+ Compare two operands using their abstract representation rather than their
385
+ value as in compare_total(), but ignoring the sign of each operand.
386
+
387
+ x.compare_total_mag(y) is equivalent to x.copy_abs().compare_total(y.copy_abs()).
388
+
389
+ This operation is unaffected by context and is quiet: no flags are changed
390
+ and no rounding is performed. As an exception, the C version may raise
391
+ InvalidOperation if the second operand cannot be converted exactly.
392
+ """
393
+ ...
394
+ def copy_abs(self) -> Decimal:
395
+ """
396
+ Return the absolute value of the argument. This operation is unaffected by
397
+ context and is quiet: no flags are changed and no rounding is performed.
398
+ """
399
+ ...
400
+ def copy_negate(self) -> Decimal:
401
+ """
402
+ Return the negation of the argument. This operation is unaffected by context
403
+ and is quiet: no flags are changed and no rounding is performed.
404
+ """
405
+ ...
406
+ def copy_sign(self, other: _Decimal, context: Context | None = None) -> Decimal:
407
+ """
408
+ Return a copy of the first operand with the sign set to be the same as the
409
+ sign of the second operand. For example:
410
+
411
+ >>> Decimal('2.3').copy_sign(Decimal('-1.5'))
412
+ Decimal('-2.3')
413
+
414
+ This operation is unaffected by context and is quiet: no flags are changed
415
+ and no rounding is performed. As an exception, the C version may raise
416
+ InvalidOperation if the second operand cannot be converted exactly.
417
+ """
418
+ ...
419
+ def exp(self, context: Context | None = None) -> Decimal:
420
+ """
421
+ Return the value of the (natural) exponential function e**x at the given
422
+ number. The function always uses the ROUND_HALF_EVEN mode and the result
423
+ is correctly rounded.
424
+ """
425
+ ...
426
+ def is_canonical(self) -> bool:
427
+ """
428
+ Return True if the argument is canonical and False otherwise. Currently,
429
+ a Decimal instance is always canonical, so this operation always returns
430
+ True.
431
+ """
432
+ ...
433
+ def is_finite(self) -> bool:
434
+ """
435
+ Return True if the argument is a finite number, and False if the argument
436
+ is infinite or a NaN.
437
+ """
438
+ ...
439
+ def is_infinite(self) -> bool:
440
+ """
441
+ Return True if the argument is either positive or negative infinity and
442
+ False otherwise.
443
+ """
444
+ ...
445
+ def is_nan(self) -> bool:
446
+ """
447
+ Return True if the argument is a (quiet or signaling) NaN and False
448
+ otherwise.
449
+ """
450
+ ...
451
+ def is_normal(self, context: Context | None = None) -> bool:
452
+ """
453
+ Return True if the argument is a normal finite non-zero number with an
454
+ adjusted exponent greater than or equal to Emin. Return False if the
455
+ argument is zero, subnormal, infinite or a NaN.
456
+ """
457
+ ...
458
+ def is_qnan(self) -> bool:
459
+ """Return True if the argument is a quiet NaN, and False otherwise."""
460
+ ...
461
+ def is_signed(self) -> bool:
462
+ """
463
+ Return True if the argument has a negative sign and False otherwise.
464
+ Note that both zeros and NaNs can carry signs.
465
+ """
466
+ ...
467
+ def is_snan(self) -> bool:
468
+ """Return True if the argument is a signaling NaN and False otherwise."""
469
+ ...
470
+ def is_subnormal(self, context: Context | None = None) -> bool:
471
+ """
472
+ Return True if the argument is subnormal, and False otherwise. A number is
473
+ subnormal if it is non-zero, finite, and has an adjusted exponent less
474
+ than Emin.
475
+ """
476
+ ...
477
+ def is_zero(self) -> bool:
478
+ """
479
+ Return True if the argument is a (positive or negative) zero and False
480
+ otherwise.
481
+ """
482
+ ...
483
+ def ln(self, context: Context | None = None) -> Decimal:
484
+ """
485
+ Return the natural (base e) logarithm of the operand. The function always
486
+ uses the ROUND_HALF_EVEN mode and the result is correctly rounded.
487
+ """
488
+ ...
489
+ def log10(self, context: Context | None = None) -> Decimal:
490
+ """
491
+ Return the base ten logarithm of the operand. The function always uses the
492
+ ROUND_HALF_EVEN mode and the result is correctly rounded.
493
+ """
494
+ ...
495
+ def logb(self, context: Context | None = None) -> Decimal:
496
+ """
497
+ For a non-zero number, return the adjusted exponent of the operand as a
498
+ Decimal instance. If the operand is a zero, then Decimal('-Infinity') is
499
+ returned and the DivisionByZero condition is raised. If the operand is
500
+ an infinity then Decimal('Infinity') is returned.
501
+ """
502
+ ...
503
+ def logical_and(self, other: _Decimal, context: Context | None = None) -> Decimal:
504
+ """Return the digit-wise 'and' of the two (logical) operands."""
505
+ ...
506
+ def logical_invert(self, context: Context | None = None) -> Decimal:
507
+ """Return the digit-wise inversion of the (logical) operand."""
508
+ ...
509
+ def logical_or(self, other: _Decimal, context: Context | None = None) -> Decimal:
510
+ """Return the digit-wise 'or' of the two (logical) operands."""
511
+ ...
512
+ def logical_xor(self, other: _Decimal, context: Context | None = None) -> Decimal:
513
+ """Return the digit-wise 'exclusive or' of the two (logical) operands."""
514
+ ...
515
+ def max_mag(self, other: _Decimal, context: Context | None = None) -> Decimal:
516
+ """
517
+ Similar to the max() method, but the comparison is done using the absolute
518
+ values of the operands.
519
+ """
520
+ ...
521
+ def min_mag(self, other: _Decimal, context: Context | None = None) -> Decimal:
522
+ """
523
+ Similar to the min() method, but the comparison is done using the absolute
524
+ values of the operands.
525
+ """
526
+ ...
527
+ def next_minus(self, context: Context | None = None) -> Decimal:
528
+ """
529
+ Return the largest number representable in the given context (or in the
530
+ current default context if no context is given) that is smaller than the
531
+ given operand.
532
+ """
533
+ ...
534
+ def next_plus(self, context: Context | None = None) -> Decimal:
535
+ """
536
+ Return the smallest number representable in the given context (or in the
537
+ current default context if no context is given) that is larger than the
538
+ given operand.
539
+ """
540
+ ...
541
+ def next_toward(self, other: _Decimal, context: Context | None = None) -> Decimal:
542
+ """
543
+ If the two operands are unequal, return the number closest to the first
544
+ operand in the direction of the second operand. If both operands are
545
+ numerically equal, return a copy of the first operand with the sign set
546
+ to be the same as the sign of the second operand.
547
+ """
548
+ ...
549
+ def number_class(self, context: Context | None = None) -> str:
550
+ """
551
+ Return a string describing the class of the operand. The returned value
552
+ is one of the following ten strings:
553
+
554
+ * '-Infinity', indicating that the operand is negative infinity.
555
+ * '-Normal', indicating that the operand is a negative normal number.
556
+ * '-Subnormal', indicating that the operand is negative and subnormal.
557
+ * '-Zero', indicating that the operand is a negative zero.
558
+ * '+Zero', indicating that the operand is a positive zero.
559
+ * '+Subnormal', indicating that the operand is positive and subnormal.
560
+ * '+Normal', indicating that the operand is a positive normal number.
561
+ * '+Infinity', indicating that the operand is positive infinity.
562
+ * 'NaN', indicating that the operand is a quiet NaN (Not a Number).
563
+ * 'sNaN', indicating that the operand is a signaling NaN.
564
+ """
565
+ ...
566
+ def radix(self) -> Decimal:
567
+ """
568
+ Return Decimal(10), the radix (base) in which the Decimal class does
569
+ all its arithmetic. Included for compatibility with the specification.
570
+ """
571
+ ...
572
+ def rotate(self, other: _Decimal, context: Context | None = None) -> Decimal:
573
+ """
574
+ Return the result of rotating the digits of the first operand by an amount
575
+ specified by the second operand. The second operand must be an integer in
576
+ the range -precision through precision. The absolute value of the second
577
+ operand gives the number of places to rotate. If the second operand is
578
+ positive then rotation is to the left; otherwise rotation is to the right.
579
+ The coefficient of the first operand is padded on the left with zeros to
580
+ length precision if necessary. The sign and exponent of the first operand are
581
+ unchanged.
582
+ """
583
+ ...
584
+ def scaleb(self, other: _Decimal, context: Context | None = None) -> Decimal:
585
+ """
586
+ Return the first operand with the exponent adjusted the second. Equivalently,
587
+ return the first operand multiplied by 10**other. The second operand must be
588
+ an integer.
589
+ """
590
+ ...
591
+ def shift(self, other: _Decimal, context: Context | None = None) -> Decimal:
592
+ """
593
+ Return the result of shifting the digits of the first operand by an amount
594
+ specified by the second operand. The second operand must be an integer in
595
+ the range -precision through precision. The absolute value of the second
596
+ operand gives the number of places to shift. If the second operand is
597
+ positive, then the shift is to the left; otherwise the shift is to the
598
+ right. Digits shifted into the coefficient are zeros. The sign and exponent
599
+ of the first operand are unchanged.
600
+ """
601
+ ...
166
602
  def __reduce__(self) -> tuple[type[Self], tuple[str]]: ...
167
603
  def __copy__(self) -> Self: ...
168
604
  def __deepcopy__(self, memo: Any, /) -> Self: ...
@@ -178,6 +614,17 @@ class _ContextManager:
178
614
  _TrapType: TypeAlias = type[DecimalException]
179
615
 
180
616
  class Context:
617
+ """
618
+ The context affects almost all operations and controls rounding,
619
+ Over/Underflow, raising of exceptions and much more. A new context
620
+ can be constructed as follows:
621
+
622
+ >>> c = Context(prec=28, Emin=-425000000, Emax=425000000,
623
+ ... rounding=ROUND_HALF_EVEN, capitals=1, clamp=1,
624
+ ... traps=[InvalidOperation, DivisionByZero, Overflow],
625
+ ... flags=[])
626
+ >>>
627
+ """
181
628
  # TODO: Context doesn't allow you to delete *any* attributes from instances of the class at runtime,
182
629
  # even settable attributes like `prec` and `rounding`,
183
630
  # but that's inexpressable in the stub.
@@ -204,77 +651,252 @@ class Context:
204
651
  _ignored_flags: list[_TrapType] | None = ...,
205
652
  ) -> None: ...
206
653
  def __reduce__(self) -> tuple[type[Self], tuple[Any, ...]]: ...
207
- def clear_flags(self) -> None: ...
208
- def clear_traps(self) -> None: ...
209
- def copy(self) -> Context: ...
654
+ def clear_flags(self) -> None:
655
+ """Reset all flags to False."""
656
+ ...
657
+ def clear_traps(self) -> None:
658
+ """Set all traps to False."""
659
+ ...
660
+ def copy(self) -> Context:
661
+ """Return a duplicate of the context with all flags cleared."""
662
+ ...
210
663
  def __copy__(self) -> Context: ...
211
664
  # see https://github.com/python/cpython/issues/94107
212
665
  __hash__: ClassVar[None] # type: ignore[assignment]
213
- def Etiny(self) -> int: ...
214
- def Etop(self) -> int: ...
215
- def create_decimal(self, num: _DecimalNew = "0", /) -> Decimal: ...
216
- def create_decimal_from_float(self, f: float, /) -> Decimal: ...
217
- def abs(self, x: _Decimal, /) -> Decimal: ...
218
- def add(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
219
- def canonical(self, x: Decimal, /) -> Decimal: ...
220
- def compare(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
221
- def compare_signal(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
222
- def compare_total(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
223
- def compare_total_mag(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
224
- def copy_abs(self, x: _Decimal, /) -> Decimal: ...
225
- def copy_decimal(self, x: _Decimal, /) -> Decimal: ...
226
- def copy_negate(self, x: _Decimal, /) -> Decimal: ...
227
- def copy_sign(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
228
- def divide(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
229
- def divide_int(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
230
- def divmod(self, x: _Decimal, y: _Decimal, /) -> tuple[Decimal, Decimal]: ...
231
- def exp(self, x: _Decimal, /) -> Decimal: ...
232
- def fma(self, x: _Decimal, y: _Decimal, z: _Decimal, /) -> Decimal: ...
233
- def is_canonical(self, x: _Decimal, /) -> bool: ...
234
- def is_finite(self, x: _Decimal, /) -> bool: ...
235
- def is_infinite(self, x: _Decimal, /) -> bool: ...
236
- def is_nan(self, x: _Decimal, /) -> bool: ...
237
- def is_normal(self, x: _Decimal, /) -> bool: ...
238
- def is_qnan(self, x: _Decimal, /) -> bool: ...
239
- def is_signed(self, x: _Decimal, /) -> bool: ...
240
- def is_snan(self, x: _Decimal, /) -> bool: ...
241
- def is_subnormal(self, x: _Decimal, /) -> bool: ...
242
- def is_zero(self, x: _Decimal, /) -> bool: ...
243
- def ln(self, x: _Decimal, /) -> Decimal: ...
244
- def log10(self, x: _Decimal, /) -> Decimal: ...
245
- def logb(self, x: _Decimal, /) -> Decimal: ...
246
- def logical_and(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
247
- def logical_invert(self, x: _Decimal, /) -> Decimal: ...
248
- def logical_or(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
249
- def logical_xor(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
250
- def max(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
251
- def max_mag(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
252
- def min(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
253
- def min_mag(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
254
- def minus(self, x: _Decimal, /) -> Decimal: ...
255
- def multiply(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
256
- def next_minus(self, x: _Decimal, /) -> Decimal: ...
257
- def next_plus(self, x: _Decimal, /) -> Decimal: ...
258
- def next_toward(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
259
- def normalize(self, x: _Decimal, /) -> Decimal: ...
260
- def number_class(self, x: _Decimal, /) -> str: ...
261
- def plus(self, x: _Decimal, /) -> Decimal: ...
262
- def power(self, a: _Decimal, b: _Decimal, modulo: _Decimal | None = None) -> Decimal: ...
263
- def quantize(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
264
- def radix(self) -> Decimal: ...
265
- def remainder(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
266
- def remainder_near(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
267
- def rotate(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
268
- def same_quantum(self, x: _Decimal, y: _Decimal, /) -> bool: ...
269
- def scaleb(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
270
- def shift(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
271
- def sqrt(self, x: _Decimal, /) -> Decimal: ...
272
- def subtract(self, x: _Decimal, y: _Decimal, /) -> Decimal: ...
273
- def to_eng_string(self, x: _Decimal, /) -> str: ...
274
- def to_sci_string(self, x: _Decimal, /) -> str: ...
275
- def to_integral_exact(self, x: _Decimal, /) -> Decimal: ...
276
- def to_integral_value(self, x: _Decimal, /) -> Decimal: ...
277
- def to_integral(self, x: _Decimal, /) -> Decimal: ...
666
+ def Etiny(self) -> int:
667
+ """
668
+ Return a value equal to Emin - prec + 1, which is the minimum exponent value
669
+ for subnormal results. When underflow occurs, the exponent is set to Etiny.
670
+ """
671
+ ...
672
+ def Etop(self) -> int:
673
+ """
674
+ Return a value equal to Emax - prec + 1. This is the maximum exponent
675
+ if the _clamp field of the context is set to 1 (IEEE clamp mode). Etop()
676
+ must not be negative.
677
+ """
678
+ ...
679
+ def create_decimal(self, num: _DecimalNew = "0", /) -> Decimal:
680
+ """
681
+ Create a new Decimal instance from num, using self as the context. Unlike the
682
+ Decimal constructor, this function observes the context limits.
683
+ """
684
+ ...
685
+ def create_decimal_from_float(self, f: float, /) -> Decimal:
686
+ """
687
+ Create a new Decimal instance from float f. Unlike the Decimal.from_float()
688
+ class method, this function observes the context limits.
689
+ """
690
+ ...
691
+ def abs(self, x: _Decimal, /) -> Decimal:
692
+ """Return the absolute value of x."""
693
+ ...
694
+ def add(self, x: _Decimal, y: _Decimal, /) -> Decimal:
695
+ """Return the sum of x and y."""
696
+ ...
697
+ def canonical(self, x: Decimal, /) -> Decimal:
698
+ """Return a new instance of x."""
699
+ ...
700
+ def compare(self, x: _Decimal, y: _Decimal, /) -> Decimal:
701
+ """Compare x and y numerically."""
702
+ ...
703
+ def compare_signal(self, x: _Decimal, y: _Decimal, /) -> Decimal:
704
+ """Compare x and y numerically. All NaNs signal."""
705
+ ...
706
+ def compare_total(self, x: _Decimal, y: _Decimal, /) -> Decimal:
707
+ """Compare x and y using their abstract representation."""
708
+ ...
709
+ def compare_total_mag(self, x: _Decimal, y: _Decimal, /) -> Decimal:
710
+ """Compare x and y using their abstract representation, ignoring sign."""
711
+ ...
712
+ def copy_abs(self, x: _Decimal, /) -> Decimal:
713
+ """Return a copy of x with the sign set to 0."""
714
+ ...
715
+ def copy_decimal(self, x: _Decimal, /) -> Decimal:
716
+ """Return a copy of Decimal x."""
717
+ ...
718
+ def copy_negate(self, x: _Decimal, /) -> Decimal:
719
+ """Return a copy of x with the sign inverted."""
720
+ ...
721
+ def copy_sign(self, x: _Decimal, y: _Decimal, /) -> Decimal:
722
+ """Copy the sign from y to x."""
723
+ ...
724
+ def divide(self, x: _Decimal, y: _Decimal, /) -> Decimal:
725
+ """Return x divided by y."""
726
+ ...
727
+ def divide_int(self, x: _Decimal, y: _Decimal, /) -> Decimal:
728
+ """Return x divided by y, truncated to an integer."""
729
+ ...
730
+ def divmod(self, x: _Decimal, y: _Decimal, /) -> tuple[Decimal, Decimal]:
731
+ """Return quotient and remainder of the division x / y."""
732
+ ...
733
+ def exp(self, x: _Decimal, /) -> Decimal:
734
+ """Return e ** x."""
735
+ ...
736
+ def fma(self, x: _Decimal, y: _Decimal, z: _Decimal, /) -> Decimal:
737
+ """Return x multiplied by y, plus z."""
738
+ ...
739
+ def is_canonical(self, x: _Decimal, /) -> bool:
740
+ """Return True if x is canonical, False otherwise."""
741
+ ...
742
+ def is_finite(self, x: _Decimal, /) -> bool:
743
+ """Return True if x is finite, False otherwise."""
744
+ ...
745
+ def is_infinite(self, x: _Decimal, /) -> bool:
746
+ """Return True if x is infinite, False otherwise."""
747
+ ...
748
+ def is_nan(self, x: _Decimal, /) -> bool:
749
+ """Return True if x is a qNaN or sNaN, False otherwise."""
750
+ ...
751
+ def is_normal(self, x: _Decimal, /) -> bool:
752
+ """Return True if x is a normal number, False otherwise."""
753
+ ...
754
+ def is_qnan(self, x: _Decimal, /) -> bool:
755
+ """Return True if x is a quiet NaN, False otherwise."""
756
+ ...
757
+ def is_signed(self, x: _Decimal, /) -> bool:
758
+ """Return True if x is negative, False otherwise."""
759
+ ...
760
+ def is_snan(self, x: _Decimal, /) -> bool:
761
+ """Return True if x is a signaling NaN, False otherwise."""
762
+ ...
763
+ def is_subnormal(self, x: _Decimal, /) -> bool:
764
+ """Return True if x is subnormal, False otherwise."""
765
+ ...
766
+ def is_zero(self, x: _Decimal, /) -> bool:
767
+ """Return True if x is a zero, False otherwise."""
768
+ ...
769
+ def ln(self, x: _Decimal, /) -> Decimal:
770
+ """Return the natural (base e) logarithm of x."""
771
+ ...
772
+ def log10(self, x: _Decimal, /) -> Decimal:
773
+ """Return the base 10 logarithm of x."""
774
+ ...
775
+ def logb(self, x: _Decimal, /) -> Decimal:
776
+ """Return the exponent of the magnitude of the operand's MSD."""
777
+ ...
778
+ def logical_and(self, x: _Decimal, y: _Decimal, /) -> Decimal:
779
+ """Digit-wise and of x and y."""
780
+ ...
781
+ def logical_invert(self, x: _Decimal, /) -> Decimal:
782
+ """Invert all digits of x."""
783
+ ...
784
+ def logical_or(self, x: _Decimal, y: _Decimal, /) -> Decimal:
785
+ """Digit-wise or of x and y."""
786
+ ...
787
+ def logical_xor(self, x: _Decimal, y: _Decimal, /) -> Decimal:
788
+ """Digit-wise xor of x and y."""
789
+ ...
790
+ def max(self, x: _Decimal, y: _Decimal, /) -> Decimal:
791
+ """Compare the values numerically and return the maximum."""
792
+ ...
793
+ def max_mag(self, x: _Decimal, y: _Decimal, /) -> Decimal:
794
+ """Compare the values numerically with their sign ignored."""
795
+ ...
796
+ def min(self, x: _Decimal, y: _Decimal, /) -> Decimal:
797
+ """Compare the values numerically and return the minimum."""
798
+ ...
799
+ def min_mag(self, x: _Decimal, y: _Decimal, /) -> Decimal:
800
+ """Compare the values numerically with their sign ignored."""
801
+ ...
802
+ def minus(self, x: _Decimal, /) -> Decimal:
803
+ """
804
+ Minus corresponds to the unary prefix minus operator in Python, but applies
805
+ the context to the result.
806
+ """
807
+ ...
808
+ def multiply(self, x: _Decimal, y: _Decimal, /) -> Decimal:
809
+ """Return the product of x and y."""
810
+ ...
811
+ def next_minus(self, x: _Decimal, /) -> Decimal:
812
+ """Return the largest representable number smaller than x."""
813
+ ...
814
+ def next_plus(self, x: _Decimal, /) -> Decimal:
815
+ """Return the smallest representable number larger than x."""
816
+ ...
817
+ def next_toward(self, x: _Decimal, y: _Decimal, /) -> Decimal:
818
+ """Return the number closest to x, in the direction towards y."""
819
+ ...
820
+ def normalize(self, x: _Decimal, /) -> Decimal:
821
+ """Reduce x to its simplest form. Alias for reduce(x)."""
822
+ ...
823
+ def number_class(self, x: _Decimal, /) -> str:
824
+ """Return an indication of the class of x."""
825
+ ...
826
+ def plus(self, x: _Decimal, /) -> Decimal:
827
+ """
828
+ Plus corresponds to the unary prefix plus operator in Python, but applies
829
+ the context to the result.
830
+ """
831
+ ...
832
+ def power(self, a: _Decimal, b: _Decimal, modulo: _Decimal | None = None) -> Decimal:
833
+ """
834
+ Compute a**b. If 'a' is negative, then 'b' must be integral. The result
835
+ will be inexact unless 'a' is integral and the result is finite and can
836
+ be expressed exactly in 'precision' digits. In the Python version the
837
+ result is always correctly rounded, in the C version the result is almost
838
+ always correctly rounded.
839
+
840
+ If modulo is given, compute (a**b) % modulo. The following restrictions
841
+ hold:
842
+
843
+ * all three arguments must be integral
844
+ * 'b' must be nonnegative
845
+ * at least one of 'a' or 'b' must be nonzero
846
+ * modulo must be nonzero and less than 10**prec in absolute value
847
+ """
848
+ ...
849
+ def quantize(self, x: _Decimal, y: _Decimal, /) -> Decimal:
850
+ """Return a value equal to x (rounded), having the exponent of y."""
851
+ ...
852
+ def radix(self) -> Decimal:
853
+ """Return 10."""
854
+ ...
855
+ def remainder(self, x: _Decimal, y: _Decimal, /) -> Decimal:
856
+ """
857
+ Return the remainder from integer division. The sign of the result,
858
+ if non-zero, is the same as that of the original dividend.
859
+ """
860
+ ...
861
+ def remainder_near(self, x: _Decimal, y: _Decimal, /) -> Decimal:
862
+ """
863
+ Return x - y * n, where n is the integer nearest the exact value of x / y
864
+ (if the result is 0 then its sign will be the sign of x).
865
+ """
866
+ ...
867
+ def rotate(self, x: _Decimal, y: _Decimal, /) -> Decimal:
868
+ """Return a copy of x, rotated by y places."""
869
+ ...
870
+ def same_quantum(self, x: _Decimal, y: _Decimal, /) -> bool:
871
+ """Return True if the two operands have the same exponent."""
872
+ ...
873
+ def scaleb(self, x: _Decimal, y: _Decimal, /) -> Decimal:
874
+ """Return the first operand after adding the second value to its exp."""
875
+ ...
876
+ def shift(self, x: _Decimal, y: _Decimal, /) -> Decimal:
877
+ """Return a copy of x, shifted by y places."""
878
+ ...
879
+ def sqrt(self, x: _Decimal, /) -> Decimal:
880
+ """Square root of a non-negative number to context precision."""
881
+ ...
882
+ def subtract(self, x: _Decimal, y: _Decimal, /) -> Decimal:
883
+ """Return the difference between x and y."""
884
+ ...
885
+ def to_eng_string(self, x: _Decimal, /) -> str:
886
+ """Convert a number to a string, using engineering notation."""
887
+ ...
888
+ def to_sci_string(self, x: _Decimal, /) -> str:
889
+ """Convert a number to a string using scientific notation."""
890
+ ...
891
+ def to_integral_exact(self, x: _Decimal, /) -> Decimal:
892
+ """Round to an integer. Signal if the result is rounded or inexact."""
893
+ ...
894
+ def to_integral_value(self, x: _Decimal, /) -> Decimal:
895
+ """Round to an integer."""
896
+ ...
897
+ def to_integral(self, x: _Decimal, /) -> Decimal:
898
+ """Identical to to_integral_value(x)."""
899
+ ...
278
900
 
279
901
  DefaultContext: Context
280
902
  BasicContext: Context