Skip to content

math.prod typing incorrect #11913

Open
Open
@karolinepauls

Description

@karolinepauls

Test file (decimal_prod.py):

from decimal import Decimal
from math import prod
from typing import TYPE_CHECKING

result = prod([Decimal(1), Decimal(2)])

if TYPE_CHECKING:
    reveal_type(result)
else:
    print(type(result))

Test:

$ mypy --version
mypy 1.10.0 (compiled: yes)
$ mypy decimal_prod.py
decimal_prod.py:8: note: Revealed type is "builtins.float"
Success: no issues found in 1 source file
$ python decimal_prod.py
<class 'decimal.Decimal'>

defined here: https://github.com/python/typeshed/blob/main/stdlib/math.pyi#L102-L105

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions