Skip to content

DecimalTuple definition is incorrect#9191

@dapper91

Description

@dapper91

Current DecimalTuple definition is:

classDecimalTuple(NamedTuple): sign: intdigits: 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:

>>>fromdecimalimportDecimal>>>exponent=Decimal('NaN').as_tuple().exponent>>>print(exponent) n>>>print(type(exponent)) <class'str'>>>>

It seems like the correct definition should be like this:

classDecimalTuple(NamedTuple): sign: intdigits: tuple[int, ...] exponent: Union[int, str]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions