Bug summary
Following the docs on Spines, specifically this pattern:
spines[:].set_visible(False)
leads to a mypy error:
error: No overload variant of "__getitem__" of "Spines" matches argument type "slice" [call-overload]
note: Possible overload variants:
note: def __getitem__(self, str, /) -> Spine
note: def __getitem__(self, list[str], /) -> SpinesProxy
Code for reproduction
import matplotlib.pyplot as plt
ax = plt.gca()
ax.spines[:].set_visible(False)
Actual outcome
error: No overload variant of "__getitem__" of "Spines" matches argument type "slice" [call-overload]
note: Possible overload variants:
note: def __getitem__(self, str, /) -> Spine
note: def __getitem__(self, list[str], /) -> SpinesProxy
Expected outcome
mypy passes the above code as correctly typed.
Fix would likely be to define an overload for a slice type here:
|
class Spines(MutableMapping[str, Spine]): |
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
Bug summary
Following the docs on Spines, specifically this pattern:
leads to a
mypyerror:Code for reproduction
Actual outcome
Expected outcome
mypypasses the above code as correctly typed.Fix would likely be to define an overload for a
slicetype here:matplotlib/lib/matplotlib/spines.pyi
Line 69 in 258dd85
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