You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: type-checking errors with mypy + matplotlib 3.8.0rc1 #26501
t.py: note: In function "rgb_from_cmap":
t.py:5: error: No overload variant of "__getitem__" of "tuple" matches argument type "Tuple[slice, slice]" [call-overload]
t.py:5: note: Possible overload variants:
t.py:5: note: def __getitem__(self, SupportsIndex, /) -> float
t.py:5: note: def __getitem__(self, slice, /) -> Tuple[float, ...]
t.py:6: error: Incompatible return value type (got "Union[float, ndarray[Any, Any]]", expected "ndarray[Any, Any]") [return-value]
Found 2 errors in 1 file (checked 1 source file)
Expected outcome
no error. The second one is easy enough to handle in user code by returning np.asarray(RGB) (though I am not 100% sure that this should be necessary), but the first error really feels undesired to me;
Quoting from Colormap.__call__'s docstring:
Returns
-------
Tuple of RGBA values if X is scalar, otherwise an array of
RGBA values with a shape of ``X.shape + (4, )``.
it should be clear that the return value is necessarily an array with ndim >= 2 in my case ?
I think the problem is that the return type of this function is annotated as a union type
Activity
TYP: Add overload to specify output of Colormap.__call__ when possible