Open karolinepauls opened 2 months ago
It sounds as if we should use a TypeVar
here, but the existing overload makes me a bit anxious. Any fix should include tests to check a few use cases. (But as always: PR welcome!)
Presumably all non-int
return types should be a union with Literal[1]
. No matter what type the sequence elements are, it is possible to get the integer 1 with an empty sequence:
>>> import math
>>> math.prod([])
1
Presumably all non-
int
return types should be a union withLiteral[1]
. No matter what type the sequence elements are, it is possible to get the integer 1 with an empty sequence:>>> import math >>> math.prod([]) 1
And now try:
>>> math.prod([], start=17)
> 17
Test file (
decimal_prod.py
):Test:
defined here: https://github.com/python/typeshed/blob/main/stdlib/math.pyi#L102-L105