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
The type stubs for Figure.subplots has two @overloads. One is generic, and the other is specialised for squeeze=False (in which case the return value is always nd.ndarray). But there are also some other cases where the type could be more accurately inferred.
infer.py:4: note: Revealed type is "Union[numpy.ndarray[Any, Any], matplotlib.axes.SubplotBase, matplotlib.axes._axes.Axes]"
infer.py:5: note: Revealed type is "Union[numpy.ndarray[Any, Any], matplotlib.axes.SubplotBase, matplotlib.axes._axes.Axes]"
infer.py:6: note: Revealed type is "Union[numpy.ndarray[Any, Any], matplotlib.axes.SubplotBase, matplotlib.axes._axes.Axes]"
Expected outcome
infer.py:4: note: Revealed type is "Union[matplotlib.axes.SubplotBase, matplotlib.axes._axes.Axes]"
infer.py:5: note: Revealed type is "numpy.ndarray[Any, Any]]"
infer.py:6: note: Revealed type is "numpy.ndarray[Any, Any]]"
Additional information
The last two examples may be impossible to implement, because you'd need a way to type "a literal integer != 1". But the first case is the one I initially ran into. I was able to work around it by replacing it with fig.add_subplot(), but that isn't semantically identical.
Activity
Make mypy happy with matplotlib's type annotations
QuLogic commentedon Sep 21, 2024
I think this was already fixed by #27001.