Closed
Description
Bug summary
type-checking failing when using something like this:
plt.scatter(x_coords, y_coords, c=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6], cmap='jet_r', alpha=0.6)
saying that c
has incompatible types:
error: Argument "c" to "scatter" has incompatible type "list[float]"; expected "Sequence[tuple[float, float, float] | str | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float]] | tuple[float, float, float] | str | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] | None"
However, this actually IS allowed by underlying code for plotting since c
will sample from the cmap
function.
I suspect this will happen in any plotting function that allows this behavior.
Code for reproduction
plt.scatter([1,2,3,4,5], [1,2,3,4,5], c=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6], cmap='jet_r', alpha=0.6)
Actual outcome
mypy raises error:
error: Argument "c" to "scatter" has incompatible type "list[float]"; expected "Sequence[tuple[float, float, float] | str | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float]] | tuple[float, float, float] | str | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] | None"
Expected outcome
mypy should not raise error
Additional information
No response
Operating system
No response
Matplotlib Version
3.8.0
Matplotlib Backend
No response
Python version
No response
Jupyter version
No response
Installation
None