Closed
Description
Current DecimalTuple
definition is:
class DecimalTuple(NamedTuple):
sign: int
digits: tuple[int, ...]
exponent: int
source: https://github.com/python/typeshed/blob/main/stdlib/_decimal.pyi#L16
But if a decimal value is NaN
the exponent is of type str
. The following example illustrate that:
>>> from decimal import Decimal
>>> exponent = Decimal('NaN').as_tuple().exponent
>>> print(exponent)
n
>>> print(type(exponent))
<class 'str'>
>>>
It seems like the correct definition should be like this:
class DecimalTuple(NamedTuple):
sign: int
digits: tuple[int, ...]
exponent: Union[int, str]
Metadata
Metadata
Assignees
Labels
No labels