basedpyright 1.18.3 → 1.18.4

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 (214) hide show
  1. package/README.md +3 -3
  2. package/dist/pyright-langserver.js +1 -1
  3. package/dist/pyright-langserver.js.map +1 -1
  4. package/dist/pyright.js +1 -1
  5. package/dist/pyright.js.map +1 -1
  6. package/dist/typeshed-fallback/commit.txt +1 -1
  7. package/dist/typeshed-fallback/stdlib/VERSIONS +2 -0
  8. package/dist/typeshed-fallback/stdlib/_ast.pyi +140 -1667
  9. package/dist/typeshed-fallback/stdlib/_csv.pyi +14 -3
  10. package/dist/typeshed-fallback/stdlib/_curses.pyi +857 -65
  11. package/dist/typeshed-fallback/stdlib/_decimal.pyi +29 -820
  12. package/dist/typeshed-fallback/stdlib/_socket.pyi +4 -12
  13. package/dist/typeshed-fallback/stdlib/_sqlite3.pyi +387 -0
  14. package/dist/typeshed-fallback/stdlib/_ssl.pyi +406 -0
  15. package/dist/typeshed-fallback/stdlib/_weakref.pyi +2 -41
  16. package/dist/typeshed-fallback/stdlib/ast.pyi +1843 -172
  17. package/dist/typeshed-fallback/stdlib/builtins.pyi +5 -0
  18. package/dist/typeshed-fallback/stdlib/cProfile.pyi +3 -3
  19. package/dist/typeshed-fallback/stdlib/calendar.pyi +3 -3
  20. package/dist/typeshed-fallback/stdlib/concurrent/futures/process.pyi +3 -2
  21. package/dist/typeshed-fallback/stdlib/contextlib.pyi +6 -8
  22. package/dist/typeshed-fallback/stdlib/csv.pyi +4 -3
  23. package/dist/typeshed-fallback/stdlib/curses/__init__.pyi +7 -2
  24. package/dist/typeshed-fallback/stdlib/curses/panel.pyi +4 -4
  25. package/dist/typeshed-fallback/stdlib/curses/textpad.pyi +3 -3
  26. package/dist/typeshed-fallback/stdlib/decimal.pyi +840 -2
  27. package/dist/typeshed-fallback/stdlib/email/_policybase.pyi +27 -18
  28. package/dist/typeshed-fallback/stdlib/email/feedparser.pyi +5 -5
  29. package/dist/typeshed-fallback/stdlib/email/generator.pyi +46 -9
  30. package/dist/typeshed-fallback/stdlib/email/message.pyi +8 -6
  31. package/dist/typeshed-fallback/stdlib/email/parser.pyi +6 -4
  32. package/dist/typeshed-fallback/stdlib/email/policy.pyi +28 -10
  33. package/dist/typeshed-fallback/stdlib/http/client.pyi +3 -2
  34. package/dist/typeshed-fallback/stdlib/io.pyi +6 -22
  35. package/dist/typeshed-fallback/stdlib/multiprocessing/connection.pyi +27 -19
  36. package/dist/typeshed-fallback/stdlib/multiprocessing/context.pyi +5 -2
  37. package/dist/typeshed-fallback/stdlib/multiprocessing/managers.pyi +4 -2
  38. package/dist/typeshed-fallback/stdlib/multiprocessing/reduction.pyi +2 -2
  39. package/dist/typeshed-fallback/stdlib/profile.pyi +3 -3
  40. package/dist/typeshed-fallback/stdlib/pyexpat/__init__.pyi +1 -5
  41. package/dist/typeshed-fallback/stdlib/re.pyi +10 -1
  42. package/dist/typeshed-fallback/stdlib/socket.pyi +12 -4
  43. package/dist/typeshed-fallback/stdlib/sqlite3/__init__.pyi +739 -1
  44. package/dist/typeshed-fallback/stdlib/sqlite3/dbapi2.pyi +220 -884
  45. package/dist/typeshed-fallback/stdlib/sre_constants.pyi +1 -8
  46. package/dist/typeshed-fallback/stdlib/ssl.pyi +40 -128
  47. package/dist/typeshed-fallback/stdlib/tarfile.pyi +111 -6
  48. package/dist/typeshed-fallback/stdlib/tkinter/__init__.pyi +127 -21
  49. package/dist/typeshed-fallback/stdlib/tokenize.pyi +1 -1
  50. package/dist/typeshed-fallback/stdlib/typing.pyi +7 -7
  51. package/dist/typeshed-fallback/stdlib/typing_extensions.pyi +1 -1
  52. package/dist/typeshed-fallback/stdlib/unittest/mock.pyi +2 -2
  53. package/dist/typeshed-fallback/stdlib/weakref.pyi +49 -14
  54. package/dist/typeshed-fallback/stdlib/xml/parsers/expat/__init__.pyi +6 -0
  55. package/dist/typeshed-fallback/stdlib/xmlrpc/client.pyi +1 -1
  56. package/dist/typeshed-fallback/stdlib/xmlrpc/server.pyi +3 -2
  57. package/dist/typeshed-fallback/stdlib/zoneinfo/__init__.pyi +41 -44
  58. package/dist/typeshed-fallback/stdlib/zoneinfo/_common.pyi +13 -0
  59. package/dist/typeshed-fallback/stdlib/zoneinfo/_tzpath.pyi +13 -0
  60. package/dist/typeshed-fallback/stubs/Flask-SocketIO/METADATA.toml +1 -1
  61. package/dist/typeshed-fallback/stubs/braintree/METADATA.toml +1 -1
  62. package/dist/typeshed-fallback/stubs/braintree/braintree/error_codes.pyi +1 -0
  63. package/dist/typeshed-fallback/stubs/docutils/docutils/__init__.pyi +3 -1
  64. package/dist/typeshed-fallback/stubs/docutils/docutils/frontend.pyi +1 -2
  65. package/dist/typeshed-fallback/stubs/docutils/docutils/parsers/rst/directives/admonitions.pyi +15 -2
  66. package/dist/typeshed-fallback/stubs/docutils/docutils/readers/doctree.pyi +1 -1
  67. package/dist/typeshed-fallback/stubs/docutils/docutils/writers/__init__.pyi +21 -2
  68. package/dist/typeshed-fallback/stubs/fpdf2/fpdf/fpdf.pyi +4 -4
  69. package/dist/typeshed-fallback/stubs/greenlet/METADATA.toml +1 -1
  70. package/dist/typeshed-fallback/stubs/hdbcli/METADATA.toml +1 -1
  71. package/dist/typeshed-fallback/stubs/icalendar/METADATA.toml +5 -2
  72. package/dist/typeshed-fallback/stubs/icalendar/icalendar/__init__.pyi +49 -5
  73. package/dist/typeshed-fallback/stubs/icalendar/icalendar/cal.pyi +32 -6
  74. package/dist/typeshed-fallback/stubs/icalendar/icalendar/caselessdict.pyi +2 -0
  75. package/dist/typeshed-fallback/stubs/icalendar/icalendar/parser.pyi +25 -1
  76. package/dist/typeshed-fallback/stubs/icalendar/icalendar/parser_tools.pyi +7 -3
  77. package/dist/typeshed-fallback/stubs/icalendar/icalendar/prop.pyi +112 -72
  78. package/dist/typeshed-fallback/stubs/icalendar/icalendar/timezone/__init__.pyi +8 -0
  79. package/dist/typeshed-fallback/stubs/icalendar/icalendar/timezone/provider.pyi +29 -0
  80. package/dist/typeshed-fallback/stubs/icalendar/icalendar/timezone/pytz.pyi +22 -0
  81. package/dist/typeshed-fallback/stubs/icalendar/icalendar/timezone/tzp.pyi +30 -0
  82. package/dist/typeshed-fallback/stubs/icalendar/icalendar/timezone/zoneinfo.pyi +33 -0
  83. package/dist/typeshed-fallback/stubs/icalendar/icalendar/tools.pyi +2 -0
  84. package/dist/typeshed-fallback/stubs/icalendar/icalendar/version.pyi +8 -0
  85. package/dist/typeshed-fallback/stubs/jwcrypto/METADATA.toml +3 -0
  86. package/dist/typeshed-fallback/stubs/jwcrypto/jwcrypto/common.pyi +48 -0
  87. package/dist/typeshed-fallback/stubs/jwcrypto/jwcrypto/jwa.pyi +35 -0
  88. package/dist/typeshed-fallback/stubs/jwcrypto/jwcrypto/jwe.pyi +51 -0
  89. package/dist/typeshed-fallback/stubs/jwcrypto/jwcrypto/jwk.pyi +115 -0
  90. package/dist/typeshed-fallback/stubs/jwcrypto/jwcrypto/jws.pyi +52 -0
  91. package/dist/typeshed-fallback/stubs/jwcrypto/jwcrypto/jwt.pyi +78 -0
  92. package/dist/typeshed-fallback/stubs/m3u8/METADATA.toml +2 -0
  93. package/dist/typeshed-fallback/stubs/m3u8/m3u8/__init__.pyi +74 -0
  94. package/dist/typeshed-fallback/stubs/m3u8/m3u8/httpclient.pyi +19 -0
  95. package/dist/typeshed-fallback/stubs/m3u8/m3u8/mixins.pyi +25 -0
  96. package/dist/typeshed-fallback/stubs/m3u8/m3u8/model.pyi +406 -0
  97. package/dist/typeshed-fallback/stubs/m3u8/m3u8/parser.pyi +14 -0
  98. package/dist/typeshed-fallback/stubs/m3u8/m3u8/protocol.pyi +41 -0
  99. package/dist/typeshed-fallback/stubs/m3u8/m3u8/version_matching.pyi +5 -0
  100. package/dist/typeshed-fallback/stubs/m3u8/m3u8/version_matching_rules.pyi +24 -0
  101. package/dist/typeshed-fallback/stubs/paramiko/paramiko/transport.pyi +2 -1
  102. package/dist/typeshed-fallback/stubs/protobuf/METADATA.toml +2 -2
  103. package/dist/typeshed-fallback/stubs/protobuf/google/protobuf/descriptor_pb2.pyi +4 -3
  104. package/dist/typeshed-fallback/stubs/protobuf/google/protobuf/internal/well_known_types.pyi +0 -1
  105. package/dist/typeshed-fallback/stubs/pytz/pytz/__init__.pyi +4 -4
  106. package/dist/typeshed-fallback/stubs/pytz/pytz/tzinfo.pyi +1 -1
  107. package/dist/typeshed-fallback/stubs/qrcode/METADATA.toml +3 -2
  108. package/dist/typeshed-fallback/stubs/redis/redis/client.pyi +18 -0
  109. package/dist/typeshed-fallback/stubs/reportlab/METADATA.toml +1 -1
  110. package/dist/typeshed-fallback/stubs/reportlab/reportlab/graphics/renderPDF.pyi +2 -2
  111. package/dist/typeshed-fallback/stubs/seaborn/METADATA.toml +9 -1
  112. package/dist/typeshed-fallback/stubs/vobject/vobject/__init__.pyi +4 -0
  113. package/dist/typeshed-fallback/stubs/vobject/vobject/base.pyi +11 -2
  114. package/dist/typeshed-fallback/stubs/vobject/vobject/behavior.pyi +1 -1
  115. package/dist/typeshed-fallback/stubs/vobject/vobject/change_tz.pyi +4 -0
  116. package/dist/typeshed-fallback/stubs/vobject/vobject/ics_diff.pyi +0 -3
  117. package/dist/typeshed-fallback/stubs/vobject/vobject/vcard.pyi +1 -1
  118. package/dist/typeshed-fallback/stubs/waitress/waitress/__init__.pyi +2 -2
  119. package/package.json +1 -1
  120. package/dist/typeshed-fallback/stubs/Pillow/METADATA.toml +0 -8
  121. package/dist/typeshed-fallback/stubs/Pillow/PIL/BdfFontFile.pyi +0 -11
  122. package/dist/typeshed-fallback/stubs/Pillow/PIL/BlpImagePlugin.pyi +0 -39
  123. package/dist/typeshed-fallback/stubs/Pillow/PIL/BmpImagePlugin.pyi +0 -25
  124. package/dist/typeshed-fallback/stubs/Pillow/PIL/BufrStubImagePlugin.pyi +0 -9
  125. package/dist/typeshed-fallback/stubs/Pillow/PIL/ContainerIO.pyi +0 -14
  126. package/dist/typeshed-fallback/stubs/Pillow/PIL/CurImagePlugin.pyi +0 -6
  127. package/dist/typeshed-fallback/stubs/Pillow/PIL/DcxImagePlugin.pyi +0 -13
  128. package/dist/typeshed-fallback/stubs/Pillow/PIL/DdsImagePlugin.pyi +0 -314
  129. package/dist/typeshed-fallback/stubs/Pillow/PIL/EpsImagePlugin.pyi +0 -34
  130. package/dist/typeshed-fallback/stubs/Pillow/PIL/ExifTags.pyi +0 -347
  131. package/dist/typeshed-fallback/stubs/Pillow/PIL/FitsImagePlugin.pyi +0 -7
  132. package/dist/typeshed-fallback/stubs/Pillow/PIL/FliImagePlugin.pyi +0 -9
  133. package/dist/typeshed-fallback/stubs/Pillow/PIL/FontFile.pyi +0 -16
  134. package/dist/typeshed-fallback/stubs/Pillow/PIL/FpxImagePlugin.pyi +0 -23
  135. package/dist/typeshed-fallback/stubs/Pillow/PIL/FtexImagePlugin.pyi +0 -15
  136. package/dist/typeshed-fallback/stubs/Pillow/PIL/GbrImagePlugin.pyi +0 -11
  137. package/dist/typeshed-fallback/stubs/Pillow/PIL/GdImageFile.pyi +0 -9
  138. package/dist/typeshed-fallback/stubs/Pillow/PIL/GifImagePlugin.pyi +0 -31
  139. package/dist/typeshed-fallback/stubs/Pillow/PIL/GimpGradientFile.pyi +0 -19
  140. package/dist/typeshed-fallback/stubs/Pillow/PIL/GimpPaletteFile.pyi +0 -7
  141. package/dist/typeshed-fallback/stubs/Pillow/PIL/GribStubImagePlugin.pyi +0 -9
  142. package/dist/typeshed-fallback/stubs/Pillow/PIL/Hdf5StubImagePlugin.pyi +0 -9
  143. package/dist/typeshed-fallback/stubs/Pillow/PIL/IcnsImagePlugin.pyi +0 -36
  144. package/dist/typeshed-fallback/stubs/Pillow/PIL/IcoImagePlugin.pyi +0 -26
  145. package/dist/typeshed-fallback/stubs/Pillow/PIL/ImImagePlugin.pyi +0 -34
  146. package/dist/typeshed-fallback/stubs/Pillow/PIL/Image.pyi +0 -342
  147. package/dist/typeshed-fallback/stubs/Pillow/PIL/ImageChops.pyi +0 -23
  148. package/dist/typeshed-fallback/stubs/Pillow/PIL/ImageCms.pyi +0 -84
  149. package/dist/typeshed-fallback/stubs/Pillow/PIL/ImageColor.pyi +0 -10
  150. package/dist/typeshed-fallback/stubs/Pillow/PIL/ImageDraw.pyi +0 -155
  151. package/dist/typeshed-fallback/stubs/Pillow/PIL/ImageDraw2.pyi +0 -37
  152. package/dist/typeshed-fallback/stubs/Pillow/PIL/ImageEnhance.pyi +0 -25
  153. package/dist/typeshed-fallback/stubs/Pillow/PIL/ImageFile.pyi +0 -89
  154. package/dist/typeshed-fallback/stubs/Pillow/PIL/ImageFilter.pyi +0 -136
  155. package/dist/typeshed-fallback/stubs/Pillow/PIL/ImageFont.pyi +0 -114
  156. package/dist/typeshed-fallback/stubs/Pillow/PIL/ImageGrab.pyi +0 -36
  157. package/dist/typeshed-fallback/stubs/Pillow/PIL/ImageMath.pyi +0 -49
  158. package/dist/typeshed-fallback/stubs/Pillow/PIL/ImageMode.pyi +0 -10
  159. package/dist/typeshed-fallback/stubs/Pillow/PIL/ImageMorph.pyi +0 -26
  160. package/dist/typeshed-fallback/stubs/Pillow/PIL/ImageOps.pyi +0 -53
  161. package/dist/typeshed-fallback/stubs/Pillow/PIL/ImagePalette.pyi +0 -26
  162. package/dist/typeshed-fallback/stubs/Pillow/PIL/ImagePath.pyi +0 -3
  163. package/dist/typeshed-fallback/stubs/Pillow/PIL/ImageQt.pyi +0 -26
  164. package/dist/typeshed-fallback/stubs/Pillow/PIL/ImageSequence.pyi +0 -14
  165. package/dist/typeshed-fallback/stubs/Pillow/PIL/ImageShow.pyi +0 -58
  166. package/dist/typeshed-fallback/stubs/Pillow/PIL/ImageStat.pyi +0 -14
  167. package/dist/typeshed-fallback/stubs/Pillow/PIL/ImageTk.pyi +0 -51
  168. package/dist/typeshed-fallback/stubs/Pillow/PIL/ImageTransform.pyi +0 -21
  169. package/dist/typeshed-fallback/stubs/Pillow/PIL/ImageWin.pyi +0 -38
  170. package/dist/typeshed-fallback/stubs/Pillow/PIL/ImtImagePlugin.pyi +0 -10
  171. package/dist/typeshed-fallback/stubs/Pillow/PIL/IptcImagePlugin.pyi +0 -23
  172. package/dist/typeshed-fallback/stubs/Pillow/PIL/Jpeg2KImagePlugin.pyi +0 -23
  173. package/dist/typeshed-fallback/stubs/Pillow/PIL/JpegImagePlugin.pyi +0 -30
  174. package/dist/typeshed-fallback/stubs/Pillow/PIL/JpegPresets.pyi +0 -3
  175. package/dist/typeshed-fallback/stubs/Pillow/PIL/McIdasImagePlugin.pyi +0 -7
  176. package/dist/typeshed-fallback/stubs/Pillow/PIL/MicImagePlugin.pyi +0 -18
  177. package/dist/typeshed-fallback/stubs/Pillow/PIL/MpegImagePlugin.pyi +0 -18
  178. package/dist/typeshed-fallback/stubs/Pillow/PIL/MpoImagePlugin.pyi +0 -15
  179. package/dist/typeshed-fallback/stubs/Pillow/PIL/MspImagePlugin.pyi +0 -10
  180. package/dist/typeshed-fallback/stubs/Pillow/PIL/PSDraw.pyi +0 -19
  181. package/dist/typeshed-fallback/stubs/Pillow/PIL/PaletteFile.pyi +0 -7
  182. package/dist/typeshed-fallback/stubs/Pillow/PIL/PalmImagePlugin.pyi +0 -5
  183. package/dist/typeshed-fallback/stubs/Pillow/PIL/PcdImagePlugin.pyi +0 -10
  184. package/dist/typeshed-fallback/stubs/Pillow/PIL/PcfFontFile.pyi +0 -25
  185. package/dist/typeshed-fallback/stubs/Pillow/PIL/PcxImagePlugin.pyi +0 -10
  186. package/dist/typeshed-fallback/stubs/Pillow/PIL/PdfParser.pyi +0 -167
  187. package/dist/typeshed-fallback/stubs/Pillow/PIL/PixarImagePlugin.pyi +0 -7
  188. package/dist/typeshed-fallback/stubs/Pillow/PIL/PngImagePlugin.pyi +0 -115
  189. package/dist/typeshed-fallback/stubs/Pillow/PIL/PpmImagePlugin.pyi +0 -17
  190. package/dist/typeshed-fallback/stubs/Pillow/PIL/PsdImagePlugin.pyi +0 -17
  191. package/dist/typeshed-fallback/stubs/Pillow/PIL/PyAccess.pyi +0 -69
  192. package/dist/typeshed-fallback/stubs/Pillow/PIL/QoiImagePlugin.pyi +0 -11
  193. package/dist/typeshed-fallback/stubs/Pillow/PIL/SgiImagePlugin.pyi +0 -13
  194. package/dist/typeshed-fallback/stubs/Pillow/PIL/SpiderImagePlugin.pyi +0 -28
  195. package/dist/typeshed-fallback/stubs/Pillow/PIL/SunImagePlugin.pyi +0 -7
  196. package/dist/typeshed-fallback/stubs/Pillow/PIL/TarIO.pyi +0 -12
  197. package/dist/typeshed-fallback/stubs/Pillow/PIL/TgaImagePlugin.pyi +0 -12
  198. package/dist/typeshed-fallback/stubs/Pillow/PIL/TiffImagePlugin.pyi +0 -295
  199. package/dist/typeshed-fallback/stubs/Pillow/PIL/TiffTags.pyi +0 -46
  200. package/dist/typeshed-fallback/stubs/Pillow/PIL/WalImageFile.pyi +0 -14
  201. package/dist/typeshed-fallback/stubs/Pillow/PIL/WebPImagePlugin.pyi +0 -18
  202. package/dist/typeshed-fallback/stubs/Pillow/PIL/WmfImagePlugin.pyi +0 -19
  203. package/dist/typeshed-fallback/stubs/Pillow/PIL/XVThumbImagePlugin.pyi +0 -9
  204. package/dist/typeshed-fallback/stubs/Pillow/PIL/XbmImagePlugin.pyi +0 -10
  205. package/dist/typeshed-fallback/stubs/Pillow/PIL/XpmImagePlugin.pyi +0 -11
  206. package/dist/typeshed-fallback/stubs/Pillow/PIL/__init__.pyi +0 -3
  207. package/dist/typeshed-fallback/stubs/Pillow/PIL/_binary.pyi +0 -13
  208. package/dist/typeshed-fallback/stubs/Pillow/PIL/_imaging.pyi +0 -29
  209. package/dist/typeshed-fallback/stubs/Pillow/PIL/_tkinter_finder.pyi +0 -2
  210. package/dist/typeshed-fallback/stubs/Pillow/PIL/_version.pyi +0 -1
  211. package/dist/typeshed-fallback/stubs/Pillow/PIL/features.pyi +0 -23
  212. package/dist/typeshed-fallback/stubs/icalendar/icalendar/timezone_cache.pyi +0 -0
  213. /package/dist/typeshed-fallback/stubs/icalendar/icalendar/{windows_to_olson.pyi → timezone/windows_to_olson.pyi} +0 -0
  214. /package/dist/typeshed-fallback/stubs/{Pillow/PIL/PdfImagePlugin.pyi → jwcrypto/jwcrypto/__init__.pyi} +0 -0
@@ -1,24 +1,41 @@
1
1
  """C decimal arithmetic module"""
2
2
 
3
- import numbers
4
3
  import sys
5
- from collections.abc import Container, Sequence
4
+ from decimal import (
5
+ Clamped as Clamped,
6
+ Context as Context,
7
+ ConversionSyntax as ConversionSyntax,
8
+ Decimal as Decimal,
9
+ DecimalException as DecimalException,
10
+ DecimalTuple as DecimalTuple,
11
+ DivisionByZero as DivisionByZero,
12
+ DivisionImpossible as DivisionImpossible,
13
+ DivisionUndefined as DivisionUndefined,
14
+ FloatOperation as FloatOperation,
15
+ Inexact as Inexact,
16
+ InvalidContext as InvalidContext,
17
+ InvalidOperation as InvalidOperation,
18
+ Overflow as Overflow,
19
+ Rounded as Rounded,
20
+ Subnormal as Subnormal,
21
+ Underflow as Underflow,
22
+ )
6
23
  from types import TracebackType
7
- from typing import Any, ClassVar, Final, Literal, NamedTuple, overload
8
- from typing_extensions import Self, TypeAlias
24
+ from typing import Final
25
+ from typing_extensions import TypeAlias
9
26
 
10
- _Decimal: TypeAlias = Decimal | int
11
- _DecimalNew: TypeAlias = Decimal | float | str | tuple[int, Sequence[int], int]
12
- _ComparableNum: TypeAlias = Decimal | float | numbers.Rational
27
+ _TrapType: TypeAlias = type[DecimalException]
28
+
29
+ class _ContextManager:
30
+ new_context: Context
31
+ saved_context: Context
32
+ def __init__(self, new_context: Context) -> None: ...
33
+ def __enter__(self) -> Context: ...
34
+ def __exit__(self, t: type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ...
13
35
 
14
36
  __version__: Final[str]
15
37
  __libmpdec_version__: Final[str]
16
38
 
17
- class DecimalTuple(NamedTuple):
18
- sign: int
19
- digits: tuple[int, ...]
20
- exponent: int | Literal["n", "N", "F"]
21
-
22
39
  ROUND_DOWN: Final[str]
23
40
  ROUND_HALF_UP: Final[str]
24
41
  ROUND_HALF_EVEN: Final[str]
@@ -34,21 +51,6 @@ MAX_PREC: Final[int]
34
51
  MIN_EMIN: Final[int]
35
52
  MIN_ETINY: Final[int]
36
53
 
37
- class DecimalException(ArithmeticError): ...
38
- class Clamped(DecimalException): ...
39
- class InvalidOperation(DecimalException): ...
40
- class ConversionSyntax(InvalidOperation): ...
41
- class DivisionByZero(DecimalException, ZeroDivisionError): ...
42
- class DivisionImpossible(InvalidOperation): ...
43
- class DivisionUndefined(InvalidOperation, ZeroDivisionError): ...
44
- class Inexact(DecimalException): ...
45
- class InvalidContext(InvalidOperation): ...
46
- class Rounded(DecimalException): ...
47
- class Subnormal(DecimalException): ...
48
- class Overflow(Inexact, Rounded): ...
49
- class Underflow(Inexact, Rounded, Subnormal): ...
50
- class FloatOperation(DecimalException, TypeError): ...
51
-
52
54
  def setcontext(context: Context, /) -> None:
53
55
  """Set a new default context."""
54
56
  ...
@@ -87,799 +89,6 @@ else:
87
89
  """
88
90
  ...
89
91
 
90
- class Decimal:
91
- def __new__(cls, value: _DecimalNew = ..., context: Context | None = ...) -> Self: ...
92
- @classmethod
93
- def from_float(cls, f: float, /) -> Self:
94
- """
95
- Class method that converts a float to a decimal number, exactly.
96
- Since 0.1 is not exactly representable in binary floating point,
97
- Decimal.from_float(0.1) is not the same as Decimal('0.1').
98
-
99
- >>> Decimal.from_float(0.1)
100
- Decimal('0.1000000000000000055511151231257827021181583404541015625')
101
- >>> Decimal.from_float(float('nan'))
102
- Decimal('NaN')
103
- >>> Decimal.from_float(float('inf'))
104
- Decimal('Infinity')
105
- >>> Decimal.from_float(float('-inf'))
106
- Decimal('-Infinity')
107
- """
108
- ...
109
- def __bool__(self) -> bool:
110
- """True if self else False"""
111
- ...
112
- def compare(self, other: _Decimal, context: Context | None = None) -> Decimal:
113
- """
114
- Compare self to other. Return a decimal value:
115
-
116
- a or b is a NaN ==> Decimal('NaN')
117
- a < b ==> Decimal('-1')
118
- a == b ==> Decimal('0')
119
- a > b ==> Decimal('1')
120
- """
121
- ...
122
- def __hash__(self) -> int:
123
- """Return hash(self)."""
124
- ...
125
- def as_tuple(self) -> DecimalTuple:
126
- """Return a tuple representation of the number."""
127
- ...
128
- def as_integer_ratio(self) -> tuple[int, int]:
129
- """
130
- Decimal.as_integer_ratio() -> (int, int)
131
-
132
- Return a pair of integers, whose ratio is exactly equal to the original
133
- Decimal and with a positive denominator. The ratio is in lowest terms.
134
- Raise OverflowError on infinities and a ValueError on NaNs.
135
- """
136
- ...
137
- def to_eng_string(self, context: Context | None = None) -> str:
138
- """
139
- Convert to an engineering-type string. Engineering notation has an exponent
140
- which is a multiple of 3, so there are up to 3 digits left of the decimal
141
- place. For example, Decimal('123E+1') is converted to Decimal('1.23E+3').
142
-
143
- The value of context.capitals determines whether the exponent sign is lower
144
- or upper case. Otherwise, the context does not affect the operation.
145
- """
146
- ...
147
- def __abs__(self) -> Decimal:
148
- """abs(self)"""
149
- ...
150
- def __add__(self, value: _Decimal, /) -> Decimal:
151
- """Return self+value."""
152
- ...
153
- def __divmod__(self, value: _Decimal, /) -> tuple[Decimal, Decimal]:
154
- """Return divmod(self, value)."""
155
- ...
156
- def __eq__(self, value: object, /) -> bool:
157
- """Return self==value."""
158
- ...
159
- def __floordiv__(self, value: _Decimal, /) -> Decimal:
160
- """Return self//value."""
161
- ...
162
- def __ge__(self, value: _ComparableNum, /) -> bool:
163
- """Return self>=value."""
164
- ...
165
- def __gt__(self, value: _ComparableNum, /) -> bool:
166
- """Return self>value."""
167
- ...
168
- def __le__(self, value: _ComparableNum, /) -> bool:
169
- """Return self<=value."""
170
- ...
171
- def __lt__(self, value: _ComparableNum, /) -> bool:
172
- """Return self<value."""
173
- ...
174
- def __mod__(self, value: _Decimal, /) -> Decimal:
175
- """Return self%value."""
176
- ...
177
- def __mul__(self, value: _Decimal, /) -> Decimal:
178
- """Return self*value."""
179
- ...
180
- def __neg__(self) -> Decimal:
181
- """-self"""
182
- ...
183
- def __pos__(self) -> Decimal:
184
- """+self"""
185
- ...
186
- def __pow__(self, value: _Decimal, mod: _Decimal | None = None, /) -> Decimal:
187
- """Return pow(self, value, mod)."""
188
- ...
189
- def __radd__(self, value: _Decimal, /) -> Decimal:
190
- """Return value+self."""
191
- ...
192
- def __rdivmod__(self, value: _Decimal, /) -> tuple[Decimal, Decimal]:
193
- """Return divmod(value, self)."""
194
- ...
195
- def __rfloordiv__(self, value: _Decimal, /) -> Decimal:
196
- """Return value//self."""
197
- ...
198
- def __rmod__(self, value: _Decimal, /) -> Decimal:
199
- """Return value%self."""
200
- ...
201
- def __rmul__(self, value: _Decimal, /) -> Decimal:
202
- """Return value*self."""
203
- ...
204
- def __rsub__(self, value: _Decimal, /) -> Decimal:
205
- """Return value-self."""
206
- ...
207
- def __rtruediv__(self, value: _Decimal, /) -> Decimal:
208
- """Return value/self."""
209
- ...
210
- def __sub__(self, value: _Decimal, /) -> Decimal:
211
- """Return self-value."""
212
- ...
213
- def __truediv__(self, value: _Decimal, /) -> Decimal:
214
- """Return self/value."""
215
- ...
216
- def remainder_near(self, other: _Decimal, context: Context | None = None) -> Decimal:
217
- """
218
- Return the remainder from dividing self by other. This differs from
219
- self % other in that the sign of the remainder is chosen so as to minimize
220
- its absolute value. More precisely, the return value is self - n * other
221
- where n is the integer nearest to the exact value of self / other, and
222
- if two integers are equally near then the even one is chosen.
223
-
224
- If the result is zero then its sign will be the sign of self.
225
- """
226
- ...
227
- def __float__(self) -> float:
228
- """float(self)"""
229
- ...
230
- def __int__(self) -> int:
231
- """int(self)"""
232
- ...
233
- def __trunc__(self) -> int: ...
234
- @property
235
- def real(self) -> Decimal: ...
236
- @property
237
- def imag(self) -> Decimal: ...
238
- def conjugate(self) -> Decimal:
239
- """Return self."""
240
- ...
241
- def __complex__(self) -> complex: ...
242
- @overload
243
- def __round__(self) -> int: ...
244
- @overload
245
- def __round__(self, ndigits: int, /) -> Decimal: ...
246
- def __floor__(self) -> int: ...
247
- def __ceil__(self) -> int: ...
248
- def fma(self, other: _Decimal, third: _Decimal, context: Context | None = None) -> Decimal:
249
- """
250
- Fused multiply-add. Return self*other+third with no rounding of the
251
- intermediate product self*other.
252
-
253
- >>> Decimal(2).fma(3, 5)
254
- Decimal('11')
255
- """
256
- ...
257
- def __rpow__(self, value: _Decimal, mod: Context | None = None, /) -> Decimal:
258
- """Return pow(value, self, mod)."""
259
- ...
260
- def normalize(self, context: Context | None = None) -> Decimal:
261
- """
262
- Normalize the number by stripping the rightmost trailing zeros and
263
- converting any result equal to Decimal('0') to Decimal('0e0'). Used
264
- for producing canonical values for members of an equivalence class.
265
- For example, Decimal('32.100') and Decimal('0.321000e+2') both normalize
266
- to the equivalent value Decimal('32.1').
267
- """
268
- ...
269
- def quantize(self, exp: _Decimal, rounding: str | None = None, context: Context | None = None) -> Decimal:
270
- """
271
- Return a value equal to the first operand after rounding and having the
272
- exponent of the second operand.
273
-
274
- >>> Decimal('1.41421356').quantize(Decimal('1.000'))
275
- Decimal('1.414')
276
-
277
- Unlike other operations, if the length of the coefficient after the quantize
278
- operation would be greater than precision, then an InvalidOperation is signaled.
279
- This guarantees that, unless there is an error condition, the quantized exponent
280
- is always equal to that of the right-hand operand.
281
-
282
- Also unlike other operations, quantize never signals Underflow, even if the
283
- result is subnormal and inexact.
284
-
285
- If the exponent of the second operand is larger than that of the first, then
286
- rounding may be necessary. In this case, the rounding mode is determined by the
287
- rounding argument if given, else by the given context argument; if neither
288
- argument is given, the rounding mode of the current thread's context is used.
289
- """
290
- ...
291
- def same_quantum(self, other: _Decimal, context: Context | None = None) -> bool:
292
- """
293
- Test whether self and other have the same exponent or whether both are NaN.
294
-
295
- This operation is unaffected by context and is quiet: no flags are changed
296
- and no rounding is performed. As an exception, the C version may raise
297
- InvalidOperation if the second operand cannot be converted exactly.
298
- """
299
- ...
300
- def to_integral_exact(self, rounding: str | None = None, context: Context | None = None) -> Decimal:
301
- """
302
- Round to the nearest integer, signaling Inexact or Rounded as appropriate if
303
- rounding occurs. The rounding mode is determined by the rounding parameter
304
- if given, else by the given context. If neither parameter is given, then the
305
- rounding mode of the current default context is used.
306
- """
307
- ...
308
- def to_integral_value(self, rounding: str | None = None, context: Context | None = None) -> Decimal:
309
- """
310
- Round to the nearest integer without signaling Inexact or Rounded. The
311
- rounding mode is determined by the rounding parameter if given, else by
312
- the given context. If neither parameter is given, then the rounding mode
313
- of the current default context is used.
314
- """
315
- ...
316
- def to_integral(self, rounding: str | None = None, context: Context | None = None) -> Decimal:
317
- """
318
- Identical to the to_integral_value() method. The to_integral() name has been
319
- kept for compatibility with older versions.
320
- """
321
- ...
322
- def sqrt(self, context: Context | None = None) -> Decimal:
323
- """
324
- Return the square root of the argument to full precision. The result is
325
- correctly rounded using the ROUND_HALF_EVEN rounding mode.
326
- """
327
- ...
328
- def max(self, other: _Decimal, context: Context | None = None) -> Decimal:
329
- """
330
- Maximum of self and other. If one operand is a quiet NaN and the other is
331
- numeric, the numeric operand is returned.
332
- """
333
- ...
334
- def min(self, other: _Decimal, context: Context | None = None) -> Decimal:
335
- """
336
- Minimum of self and other. If one operand is a quiet NaN and the other is
337
- numeric, the numeric operand is returned.
338
- """
339
- ...
340
- def adjusted(self) -> int:
341
- """Return the adjusted exponent of the number. Defined as exp + digits - 1."""
342
- ...
343
- def canonical(self) -> Decimal:
344
- """
345
- Return the canonical encoding of the argument. Currently, the encoding
346
- of a Decimal instance is always canonical, so this operation returns its
347
- argument unchanged.
348
- """
349
- ...
350
- def compare_signal(self, other: _Decimal, context: Context | None = None) -> Decimal:
351
- """Identical to compare, except that all NaNs signal."""
352
- ...
353
- def compare_total(self, other: _Decimal, context: Context | None = None) -> Decimal:
354
- """
355
- Compare two operands using their abstract representation rather than
356
- their numerical value. Similar to the compare() method, but the result
357
- gives a total ordering on Decimal instances. Two Decimal instances with
358
- the same numeric value but different representations compare unequal
359
- in this ordering:
360
-
361
- >>> Decimal('12.0').compare_total(Decimal('12'))
362
- Decimal('-1')
363
-
364
- Quiet and signaling NaNs are also included in the total ordering. The result
365
- of this function is Decimal('0') if both operands have the same representation,
366
- Decimal('-1') if the first operand is lower in the total order than the second,
367
- and Decimal('1') if the first operand is higher in the total order than the
368
- second operand. See the specification for details of the total order.
369
-
370
- This operation is unaffected by context and is quiet: no flags are changed
371
- and no rounding is performed. As an exception, the C version may raise
372
- InvalidOperation if the second operand cannot be converted exactly.
373
- """
374
- ...
375
- def compare_total_mag(self, other: _Decimal, context: Context | None = None) -> Decimal:
376
- """
377
- Compare two operands using their abstract representation rather than their
378
- value as in compare_total(), but ignoring the sign of each operand.
379
-
380
- x.compare_total_mag(y) is equivalent to x.copy_abs().compare_total(y.copy_abs()).
381
-
382
- This operation is unaffected by context and is quiet: no flags are changed
383
- and no rounding is performed. As an exception, the C version may raise
384
- InvalidOperation if the second operand cannot be converted exactly.
385
- """
386
- ...
387
- def copy_abs(self) -> Decimal:
388
- """
389
- Return the absolute value of the argument. This operation is unaffected by
390
- context and is quiet: no flags are changed and no rounding is performed.
391
- """
392
- ...
393
- def copy_negate(self) -> Decimal:
394
- """
395
- Return the negation of the argument. This operation is unaffected by context
396
- and is quiet: no flags are changed and no rounding is performed.
397
- """
398
- ...
399
- def copy_sign(self, other: _Decimal, context: Context | None = None) -> Decimal:
400
- """
401
- Return a copy of the first operand with the sign set to be the same as the
402
- sign of the second operand. For example:
403
-
404
- >>> Decimal('2.3').copy_sign(Decimal('-1.5'))
405
- Decimal('-2.3')
406
-
407
- This operation is unaffected by context and is quiet: no flags are changed
408
- and no rounding is performed. As an exception, the C version may raise
409
- InvalidOperation if the second operand cannot be converted exactly.
410
- """
411
- ...
412
- def exp(self, context: Context | None = None) -> Decimal:
413
- """
414
- Return the value of the (natural) exponential function e**x at the given
415
- number. The function always uses the ROUND_HALF_EVEN mode and the result
416
- is correctly rounded.
417
- """
418
- ...
419
- def is_canonical(self) -> bool:
420
- """
421
- Return True if the argument is canonical and False otherwise. Currently,
422
- a Decimal instance is always canonical, so this operation always returns
423
- True.
424
- """
425
- ...
426
- def is_finite(self) -> bool:
427
- """
428
- Return True if the argument is a finite number, and False if the argument
429
- is infinite or a NaN.
430
- """
431
- ...
432
- def is_infinite(self) -> bool:
433
- """
434
- Return True if the argument is either positive or negative infinity and
435
- False otherwise.
436
- """
437
- ...
438
- def is_nan(self) -> bool:
439
- """
440
- Return True if the argument is a (quiet or signaling) NaN and False
441
- otherwise.
442
- """
443
- ...
444
- def is_normal(self, context: Context | None = None) -> bool:
445
- """
446
- Return True if the argument is a normal finite non-zero number with an
447
- adjusted exponent greater than or equal to Emin. Return False if the
448
- argument is zero, subnormal, infinite or a NaN.
449
- """
450
- ...
451
- def is_qnan(self) -> bool:
452
- """Return True if the argument is a quiet NaN, and False otherwise."""
453
- ...
454
- def is_signed(self) -> bool:
455
- """
456
- Return True if the argument has a negative sign and False otherwise.
457
- Note that both zeros and NaNs can carry signs.
458
- """
459
- ...
460
- def is_snan(self) -> bool:
461
- """Return True if the argument is a signaling NaN and False otherwise."""
462
- ...
463
- def is_subnormal(self, context: Context | None = None) -> bool:
464
- """
465
- Return True if the argument is subnormal, and False otherwise. A number is
466
- subnormal if it is non-zero, finite, and has an adjusted exponent less
467
- than Emin.
468
- """
469
- ...
470
- def is_zero(self) -> bool:
471
- """
472
- Return True if the argument is a (positive or negative) zero and False
473
- otherwise.
474
- """
475
- ...
476
- def ln(self, context: Context | None = None) -> Decimal:
477
- """
478
- Return the natural (base e) logarithm of the operand. The function always
479
- uses the ROUND_HALF_EVEN mode and the result is correctly rounded.
480
- """
481
- ...
482
- def log10(self, context: Context | None = None) -> Decimal:
483
- """
484
- Return the base ten logarithm of the operand. The function always uses the
485
- ROUND_HALF_EVEN mode and the result is correctly rounded.
486
- """
487
- ...
488
- def logb(self, context: Context | None = None) -> Decimal:
489
- """
490
- For a non-zero number, return the adjusted exponent of the operand as a
491
- Decimal instance. If the operand is a zero, then Decimal('-Infinity') is
492
- returned and the DivisionByZero condition is raised. If the operand is
493
- an infinity then Decimal('Infinity') is returned.
494
- """
495
- ...
496
- def logical_and(self, other: _Decimal, context: Context | None = None) -> Decimal:
497
- """Return the digit-wise 'and' of the two (logical) operands."""
498
- ...
499
- def logical_invert(self, context: Context | None = None) -> Decimal:
500
- """Return the digit-wise inversion of the (logical) operand."""
501
- ...
502
- def logical_or(self, other: _Decimal, context: Context | None = None) -> Decimal:
503
- """Return the digit-wise 'or' of the two (logical) operands."""
504
- ...
505
- def logical_xor(self, other: _Decimal, context: Context | None = None) -> Decimal:
506
- """Return the digit-wise 'exclusive or' of the two (logical) operands."""
507
- ...
508
- def max_mag(self, other: _Decimal, context: Context | None = None) -> Decimal:
509
- """
510
- Similar to the max() method, but the comparison is done using the absolute
511
- values of the operands.
512
- """
513
- ...
514
- def min_mag(self, other: _Decimal, context: Context | None = None) -> Decimal:
515
- """
516
- Similar to the min() method, but the comparison is done using the absolute
517
- values of the operands.
518
- """
519
- ...
520
- def next_minus(self, context: Context | None = None) -> Decimal:
521
- """
522
- Return the largest number representable in the given context (or in the
523
- current default context if no context is given) that is smaller than the
524
- given operand.
525
- """
526
- ...
527
- def next_plus(self, context: Context | None = None) -> Decimal:
528
- """
529
- Return the smallest number representable in the given context (or in the
530
- current default context if no context is given) that is larger than the
531
- given operand.
532
- """
533
- ...
534
- def next_toward(self, other: _Decimal, context: Context | None = None) -> Decimal:
535
- """
536
- If the two operands are unequal, return the number closest to the first
537
- operand in the direction of the second operand. If both operands are
538
- numerically equal, return a copy of the first operand with the sign set
539
- to be the same as the sign of the second operand.
540
- """
541
- ...
542
- def number_class(self, context: Context | None = None) -> str:
543
- """
544
- Return a string describing the class of the operand. The returned value
545
- is one of the following ten strings:
546
-
547
- * '-Infinity', indicating that the operand is negative infinity.
548
- * '-Normal', indicating that the operand is a negative normal number.
549
- * '-Subnormal', indicating that the operand is negative and subnormal.
550
- * '-Zero', indicating that the operand is a negative zero.
551
- * '+Zero', indicating that the operand is a positive zero.
552
- * '+Subnormal', indicating that the operand is positive and subnormal.
553
- * '+Normal', indicating that the operand is a positive normal number.
554
- * '+Infinity', indicating that the operand is positive infinity.
555
- * 'NaN', indicating that the operand is a quiet NaN (Not a Number).
556
- * 'sNaN', indicating that the operand is a signaling NaN.
557
- """
558
- ...
559
- def radix(self) -> Decimal:
560
- """
561
- Return Decimal(10), the radix (base) in which the Decimal class does
562
- all its arithmetic. Included for compatibility with the specification.
563
- """
564
- ...
565
- def rotate(self, other: _Decimal, context: Context | None = None) -> Decimal:
566
- """
567
- Return the result of rotating the digits of the first operand by an amount
568
- specified by the second operand. The second operand must be an integer in
569
- the range -precision through precision. The absolute value of the second
570
- operand gives the number of places to rotate. If the second operand is
571
- positive then rotation is to the left; otherwise rotation is to the right.
572
- The coefficient of the first operand is padded on the left with zeros to
573
- length precision if necessary. The sign and exponent of the first operand are
574
- unchanged.
575
- """
576
- ...
577
- def scaleb(self, other: _Decimal, context: Context | None = None) -> Decimal:
578
- """
579
- Return the first operand with the exponent adjusted the second. Equivalently,
580
- return the first operand multiplied by 10**other. The second operand must be
581
- an integer.
582
- """
583
- ...
584
- def shift(self, other: _Decimal, context: Context | None = None) -> Decimal:
585
- """
586
- Return the result of shifting the digits of the first operand by an amount
587
- specified by the second operand. The second operand must be an integer in
588
- the range -precision through precision. The absolute value of the second
589
- operand gives the number of places to shift. If the second operand is
590
- positive, then the shift is to the left; otherwise the shift is to the
591
- right. Digits shifted into the coefficient are zeros. The sign and exponent
592
- of the first operand are unchanged.
593
- """
594
- ...
595
- def __reduce__(self) -> tuple[type[Self], tuple[str]]: ...
596
- def __copy__(self) -> Self: ...
597
- def __deepcopy__(self, memo: Any, /) -> Self: ...
598
- def __format__(self, specifier: str, context: Context | None = ..., /) -> str: ...
599
-
600
- class _ContextManager:
601
- new_context: Context
602
- saved_context: Context
603
- def __init__(self, new_context: Context) -> None: ...
604
- def __enter__(self) -> Context: ...
605
- def __exit__(self, t: type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ...
606
-
607
- _TrapType: TypeAlias = type[DecimalException]
608
-
609
- class Context:
610
- # TODO: Context doesn't allow you to delete *any* attributes from instances of the class at runtime,
611
- # even settable attributes like `prec` and `rounding`,
612
- # but that's inexpressable in the stub.
613
- # Type checkers either ignore it or misinterpret it
614
- # if you add a `def __delattr__(self, name: str, /) -> NoReturn` method to the stub
615
- prec: int
616
- rounding: str
617
- Emin: int
618
- Emax: int
619
- capitals: int
620
- clamp: int
621
- traps: dict[_TrapType, bool]
622
- flags: dict[_TrapType, bool]
623
- def __init__(
624
- self,
625
- prec: int | None = ...,
626
- rounding: str | None = ...,
627
- Emin: int | None = ...,
628
- Emax: int | None = ...,
629
- capitals: int | None = ...,
630
- clamp: int | None = ...,
631
- flags: None | dict[_TrapType, bool] | Container[_TrapType] = ...,
632
- traps: None | dict[_TrapType, bool] | Container[_TrapType] = ...,
633
- _ignored_flags: list[_TrapType] | None = ...,
634
- ) -> None: ...
635
- def __reduce__(self) -> tuple[type[Self], tuple[Any, ...]]: ...
636
- def clear_flags(self) -> None:
637
- """Reset all flags to False."""
638
- ...
639
- def clear_traps(self) -> None:
640
- """Set all traps to False."""
641
- ...
642
- def copy(self) -> Context:
643
- """Return a duplicate of the context with all flags cleared."""
644
- ...
645
- def __copy__(self) -> Context: ...
646
- # see https://github.com/python/cpython/issues/94107
647
- __hash__: ClassVar[None] # type: ignore[assignment]
648
- def Etiny(self) -> int:
649
- """
650
- Return a value equal to Emin - prec + 1, which is the minimum exponent value
651
- for subnormal results. When underflow occurs, the exponent is set to Etiny.
652
- """
653
- ...
654
- def Etop(self) -> int:
655
- """
656
- Return a value equal to Emax - prec + 1. This is the maximum exponent
657
- if the _clamp field of the context is set to 1 (IEEE clamp mode). Etop()
658
- must not be negative.
659
- """
660
- ...
661
- def create_decimal(self, num: _DecimalNew = "0", /) -> Decimal:
662
- """
663
- Create a new Decimal instance from num, using self as the context. Unlike the
664
- Decimal constructor, this function observes the context limits.
665
- """
666
- ...
667
- def create_decimal_from_float(self, f: float, /) -> Decimal:
668
- """
669
- Create a new Decimal instance from float f. Unlike the Decimal.from_float()
670
- class method, this function observes the context limits.
671
- """
672
- ...
673
- def abs(self, x: _Decimal, /) -> Decimal:
674
- """Return the absolute value of x."""
675
- ...
676
- def add(self, x: _Decimal, y: _Decimal, /) -> Decimal:
677
- """Return the sum of x and y."""
678
- ...
679
- def canonical(self, x: Decimal, /) -> Decimal:
680
- """Return a new instance of x."""
681
- ...
682
- def compare(self, x: _Decimal, y: _Decimal, /) -> Decimal:
683
- """Compare x and y numerically."""
684
- ...
685
- def compare_signal(self, x: _Decimal, y: _Decimal, /) -> Decimal:
686
- """Compare x and y numerically. All NaNs signal."""
687
- ...
688
- def compare_total(self, x: _Decimal, y: _Decimal, /) -> Decimal:
689
- """Compare x and y using their abstract representation."""
690
- ...
691
- def compare_total_mag(self, x: _Decimal, y: _Decimal, /) -> Decimal:
692
- """Compare x and y using their abstract representation, ignoring sign."""
693
- ...
694
- def copy_abs(self, x: _Decimal, /) -> Decimal:
695
- """Return a copy of x with the sign set to 0."""
696
- ...
697
- def copy_decimal(self, x: _Decimal, /) -> Decimal:
698
- """Return a copy of Decimal x."""
699
- ...
700
- def copy_negate(self, x: _Decimal, /) -> Decimal:
701
- """Return a copy of x with the sign inverted."""
702
- ...
703
- def copy_sign(self, x: _Decimal, y: _Decimal, /) -> Decimal:
704
- """Copy the sign from y to x."""
705
- ...
706
- def divide(self, x: _Decimal, y: _Decimal, /) -> Decimal:
707
- """Return x divided by y."""
708
- ...
709
- def divide_int(self, x: _Decimal, y: _Decimal, /) -> Decimal:
710
- """Return x divided by y, truncated to an integer."""
711
- ...
712
- def divmod(self, x: _Decimal, y: _Decimal, /) -> tuple[Decimal, Decimal]:
713
- """Return quotient and remainder of the division x / y."""
714
- ...
715
- def exp(self, x: _Decimal, /) -> Decimal:
716
- """Return e ** x."""
717
- ...
718
- def fma(self, x: _Decimal, y: _Decimal, z: _Decimal, /) -> Decimal:
719
- """Return x multiplied by y, plus z."""
720
- ...
721
- def is_canonical(self, x: _Decimal, /) -> bool:
722
- """Return True if x is canonical, False otherwise."""
723
- ...
724
- def is_finite(self, x: _Decimal, /) -> bool:
725
- """Return True if x is finite, False otherwise."""
726
- ...
727
- def is_infinite(self, x: _Decimal, /) -> bool:
728
- """Return True if x is infinite, False otherwise."""
729
- ...
730
- def is_nan(self, x: _Decimal, /) -> bool:
731
- """Return True if x is a qNaN or sNaN, False otherwise."""
732
- ...
733
- def is_normal(self, x: _Decimal, /) -> bool:
734
- """Return True if x is a normal number, False otherwise."""
735
- ...
736
- def is_qnan(self, x: _Decimal, /) -> bool:
737
- """Return True if x is a quiet NaN, False otherwise."""
738
- ...
739
- def is_signed(self, x: _Decimal, /) -> bool:
740
- """Return True if x is negative, False otherwise."""
741
- ...
742
- def is_snan(self, x: _Decimal, /) -> bool:
743
- """Return True if x is a signaling NaN, False otherwise."""
744
- ...
745
- def is_subnormal(self, x: _Decimal, /) -> bool:
746
- """Return True if x is subnormal, False otherwise."""
747
- ...
748
- def is_zero(self, x: _Decimal, /) -> bool:
749
- """Return True if x is a zero, False otherwise."""
750
- ...
751
- def ln(self, x: _Decimal, /) -> Decimal:
752
- """Return the natural (base e) logarithm of x."""
753
- ...
754
- def log10(self, x: _Decimal, /) -> Decimal:
755
- """Return the base 10 logarithm of x."""
756
- ...
757
- def logb(self, x: _Decimal, /) -> Decimal:
758
- """Return the exponent of the magnitude of the operand's MSD."""
759
- ...
760
- def logical_and(self, x: _Decimal, y: _Decimal, /) -> Decimal:
761
- """Digit-wise and of x and y."""
762
- ...
763
- def logical_invert(self, x: _Decimal, /) -> Decimal:
764
- """Invert all digits of x."""
765
- ...
766
- def logical_or(self, x: _Decimal, y: _Decimal, /) -> Decimal:
767
- """Digit-wise or of x and y."""
768
- ...
769
- def logical_xor(self, x: _Decimal, y: _Decimal, /) -> Decimal:
770
- """Digit-wise xor of x and y."""
771
- ...
772
- def max(self, x: _Decimal, y: _Decimal, /) -> Decimal:
773
- """Compare the values numerically and return the maximum."""
774
- ...
775
- def max_mag(self, x: _Decimal, y: _Decimal, /) -> Decimal:
776
- """Compare the values numerically with their sign ignored."""
777
- ...
778
- def min(self, x: _Decimal, y: _Decimal, /) -> Decimal:
779
- """Compare the values numerically and return the minimum."""
780
- ...
781
- def min_mag(self, x: _Decimal, y: _Decimal, /) -> Decimal:
782
- """Compare the values numerically with their sign ignored."""
783
- ...
784
- def minus(self, x: _Decimal, /) -> Decimal:
785
- """
786
- Minus corresponds to the unary prefix minus operator in Python, but applies
787
- the context to the result.
788
- """
789
- ...
790
- def multiply(self, x: _Decimal, y: _Decimal, /) -> Decimal:
791
- """Return the product of x and y."""
792
- ...
793
- def next_minus(self, x: _Decimal, /) -> Decimal:
794
- """Return the largest representable number smaller than x."""
795
- ...
796
- def next_plus(self, x: _Decimal, /) -> Decimal:
797
- """Return the smallest representable number larger than x."""
798
- ...
799
- def next_toward(self, x: _Decimal, y: _Decimal, /) -> Decimal:
800
- """Return the number closest to x, in the direction towards y."""
801
- ...
802
- def normalize(self, x: _Decimal, /) -> Decimal:
803
- """Reduce x to its simplest form. Alias for reduce(x)."""
804
- ...
805
- def number_class(self, x: _Decimal, /) -> str:
806
- """Return an indication of the class of x."""
807
- ...
808
- def plus(self, x: _Decimal, /) -> Decimal:
809
- """
810
- Plus corresponds to the unary prefix plus operator in Python, but applies
811
- the context to the result.
812
- """
813
- ...
814
- def power(self, a: _Decimal, b: _Decimal, modulo: _Decimal | None = None) -> Decimal:
815
- """
816
- Compute a**b. If 'a' is negative, then 'b' must be integral. The result
817
- will be inexact unless 'a' is integral and the result is finite and can
818
- be expressed exactly in 'precision' digits. In the Python version the
819
- result is always correctly rounded, in the C version the result is almost
820
- always correctly rounded.
821
-
822
- If modulo is given, compute (a**b) % modulo. The following restrictions
823
- hold:
824
-
825
- * all three arguments must be integral
826
- * 'b' must be nonnegative
827
- * at least one of 'a' or 'b' must be nonzero
828
- * modulo must be nonzero and less than 10**prec in absolute value
829
- """
830
- ...
831
- def quantize(self, x: _Decimal, y: _Decimal, /) -> Decimal:
832
- """Return a value equal to x (rounded), having the exponent of y."""
833
- ...
834
- def radix(self) -> Decimal:
835
- """Return 10."""
836
- ...
837
- def remainder(self, x: _Decimal, y: _Decimal, /) -> Decimal:
838
- """
839
- Return the remainder from integer division. The sign of the result,
840
- if non-zero, is the same as that of the original dividend.
841
- """
842
- ...
843
- def remainder_near(self, x: _Decimal, y: _Decimal, /) -> Decimal:
844
- """
845
- Return x - y * n, where n is the integer nearest the exact value of x / y
846
- (if the result is 0 then its sign will be the sign of x).
847
- """
848
- ...
849
- def rotate(self, x: _Decimal, y: _Decimal, /) -> Decimal:
850
- """Return a copy of x, rotated by y places."""
851
- ...
852
- def same_quantum(self, x: _Decimal, y: _Decimal, /) -> bool:
853
- """Return True if the two operands have the same exponent."""
854
- ...
855
- def scaleb(self, x: _Decimal, y: _Decimal, /) -> Decimal:
856
- """Return the first operand after adding the second value to its exp."""
857
- ...
858
- def shift(self, x: _Decimal, y: _Decimal, /) -> Decimal:
859
- """Return a copy of x, shifted by y places."""
860
- ...
861
- def sqrt(self, x: _Decimal, /) -> Decimal:
862
- """Square root of a non-negative number to context precision."""
863
- ...
864
- def subtract(self, x: _Decimal, y: _Decimal, /) -> Decimal:
865
- """Return the difference between x and y."""
866
- ...
867
- def to_eng_string(self, x: _Decimal, /) -> str:
868
- """Convert a number to a string, using engineering notation."""
869
- ...
870
- def to_sci_string(self, x: _Decimal, /) -> str:
871
- """Convert a number to a string using scientific notation."""
872
- ...
873
- def to_integral_exact(self, x: _Decimal, /) -> Decimal:
874
- """Round to an integer. Signal if the result is rounded or inexact."""
875
- ...
876
- def to_integral_value(self, x: _Decimal, /) -> Decimal:
877
- """Round to an integer."""
878
- ...
879
- def to_integral(self, x: _Decimal, /) -> Decimal:
880
- """Identical to to_integral_value(x)."""
881
- ...
882
-
883
92
  DefaultContext: Context
884
93
  BasicContext: Context
885
94
  ExtendedContext: Context