Closed
Description
Currently mypy supports combining a list of integers to a list of floats:
y = [float('inf')] + list(range(10))
and the resulting type is builtins.list[builtins.float*]
.
It would be great if this worked with the collections in the reverse order:
x = list(range(10)) + [float('inf')]
Currently the latter errors with List item 0 has incompatible type "float"; expected "int"
.
I'm not sure whether this is a limitation of general support for combining generic collections, or there's something special for extending lists of floats by lists of integers.
Either way, it might also be good if this was a general thing for all collections of compatible generics.
Currently I'm using a cast
so that my code checks ok, though I'd like to be able to remove that.