Combination of collections where element types are compatible only works left-to-right #5948
Labels
bug
mypy got something wrong
false-positive
mypy gave an error on correct code
priority-1-normal
topic-type-variables
Currently mypy supports combining a list of integers to a list of floats:
and the resulting type is
builtins.list[builtins.float*]
.It would be great if this worked with the collections in the reverse order:
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.The text was updated successfully, but these errors were encountered: