Skip to content

Commit 31bff4a

Browse files
authored
Improve decimal constants and fill missing defaults (#13412)
1 parent 85ce495 commit 31bff4a

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

Diff for: stdlib/_decimal.pyi

+8-8
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ _TrapType: TypeAlias = type[DecimalException]
2727
__version__: Final[str]
2828
__libmpdec_version__: Final[str]
2929

30-
ROUND_DOWN: Final[str]
31-
ROUND_HALF_UP: Final[str]
32-
ROUND_HALF_EVEN: Final[str]
33-
ROUND_CEILING: Final[str]
34-
ROUND_FLOOR: Final[str]
35-
ROUND_UP: Final[str]
36-
ROUND_HALF_DOWN: Final[str]
37-
ROUND_05UP: Final[str]
30+
ROUND_DOWN: Final = "ROUND_DOWN"
31+
ROUND_HALF_UP: Final = "ROUND_HALF_UP"
32+
ROUND_HALF_EVEN: Final = "ROUND_HALF_EVEN"
33+
ROUND_CEILING: Final = "ROUND_CEILING"
34+
ROUND_FLOOR: Final = "ROUND_FLOOR"
35+
ROUND_UP: Final = "ROUND_UP"
36+
ROUND_HALF_DOWN: Final = "ROUND_HALF_DOWN"
37+
ROUND_05UP: Final = "ROUND_05UP"
3838
HAVE_CONTEXTVAR: Final[bool]
3939
HAVE_THREADS: Final[bool]
4040
MAX_EMAX: Final[int]

Diff for: stdlib/decimal.pyi

+11-11
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class Underflow(Inexact, Rounded, Subnormal): ...
6565
class FloatOperation(DecimalException, TypeError): ...
6666

6767
class Decimal:
68-
def __new__(cls, value: _DecimalNew = ..., context: Context | None = ...) -> Self: ...
68+
def __new__(cls, value: _DecimalNew = "0", context: Context | None = None) -> Self: ...
6969
@classmethod
7070
def from_float(cls, f: float, /) -> Self: ...
7171
def __bool__(self) -> bool: ...
@@ -163,12 +163,12 @@ class Decimal:
163163
def __reduce__(self) -> tuple[type[Self], tuple[str]]: ...
164164
def __copy__(self) -> Self: ...
165165
def __deepcopy__(self, memo: Any, /) -> Self: ...
166-
def __format__(self, specifier: str, context: Context | None = ..., /) -> str: ...
166+
def __format__(self, specifier: str, context: Context | None = None, /) -> str: ...
167167

168168
class Context:
169169
# TODO: Context doesn't allow you to delete *any* attributes from instances of the class at runtime,
170170
# even settable attributes like `prec` and `rounding`,
171-
# but that's inexpressable in the stub.
171+
# but that's inexpressible in the stub.
172172
# Type checkers either ignore it or misinterpret it
173173
# if you add a `def __delattr__(self, name: str, /) -> NoReturn` method to the stub
174174
prec: int
@@ -181,14 +181,14 @@ class Context:
181181
flags: dict[_TrapType, bool]
182182
def __init__(
183183
self,
184-
prec: int | None = ...,
185-
rounding: str | None = ...,
186-
Emin: int | None = ...,
187-
Emax: int | None = ...,
188-
capitals: int | None = ...,
189-
clamp: int | None = ...,
190-
flags: None | dict[_TrapType, bool] | Container[_TrapType] = ...,
191-
traps: None | dict[_TrapType, bool] | Container[_TrapType] = ...,
184+
prec: int | None = None,
185+
rounding: str | None = None,
186+
Emin: int | None = None,
187+
Emax: int | None = None,
188+
capitals: int | None = None,
189+
clamp: int | None = None,
190+
flags: dict[_TrapType, bool] | Container[_TrapType] | None = None,
191+
traps: dict[_TrapType, bool] | Container[_TrapType] | None = None,
192192
) -> None: ...
193193
def __reduce__(self) -> tuple[type[Self], tuple[Any, ...]]: ...
194194
def clear_flags(self) -> None: ...

0 commit comments

Comments
 (0)