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
Incorrect type annotation for _AxesBase.twinx() (should be Self, not _AxesBase).
Code for reproduction
importmatplotlib.pyplotaspltimportnumpyasnp# First create some toy data:x=np.linspace(0, 2*np.pi, 400)
y=np.sin(x**2)
z=np.cos(x**2)
# Create four polar Axes and access them through the returned arrayfig, axsA=plt.subplots()
axsA.plot(x, y)
axsB=axsA.twinx()
axsB.plot(x, z) # <-- Cannot access attribute "plot" for class "_AxesBase"
Actual outcome
axsB is of type _AxesBase
Expected outcome
The type of axsB should be the same as the type of axsA.
Matplotlib Version
3.9.1
The text was updated successfully, but these errors were encountered:
Potentially fixing this requires adding typing_extensions as a dependency, since typing.Self is not available in 3.10.
Otherwise, users might not have it in their virtual environment when installing matplotlib, leaving the stubs broken.
I made a provisional PR #28625, maintainers likely want to discuss first whether to add the extra dependency. Although imo typing_extensions is kind of must-have if you want to type the library as it is the official place for backporting new typing features.
Bug summary
Incorrect type annotation for
_AxesBase.twinx()
(should beSelf
, not_AxesBase
).Code for reproduction
Actual outcome
axsB is of type
_AxesBase
Expected outcome
The type of
axsB
should be the same as the type ofaxsA
.Matplotlib Version
3.9.1
The text was updated successfully, but these errors were encountered: