Closed
Description
When a list of unions is used, mypy will incorrectly error when a subset of the possible union types is used...
example.py:
from typing import List, Union
def mean(numbers: List[Union[int, float]]) -> float:
return sum(numbers) / len(numbers)
some_numbers = [1, 2, 3, 4]
mean(some_numbers)
console:
$ mypy --version
mypy 0.470
$ mypy example.py
example.py:7: error: Argument 1 to "mean" has incompatible type List[int]; expected List[Union[int, float]]
Presumably the inferred List[int]
ought to be able to satisfy List[Union[int, float]]
, right?
Metadata
Metadata
Assignees
Labels
No labels