pylance-release icon indicating copy to clipboard operation
pylance-release copied to clipboard

[matplotlib] Axes object missing in pyplot completion and some Axes functions too

Open alkatar21 opened this issue 1 year ago • 5 comments

In Pylance v2022.8.40 the completion works as good as the type stubs are. Since Pylance v2022.8.50 is probably microsoft/python-type-stubs#223 used.

# pyright: strict
from __future__ import annotations
from matplotlib import pyplot as plt, axes

def test(ax: plt.Axes) -> None: # axes.Axes
    ax.get_yticks()
    ax.set_xticks()

This worked until now, but now pyright is complaining: grafik Even if I use axes.Axes, the functions are still unknown.

One thing I noticed, but don't know if it's relevant, is that F12 used to lead to the .pyi files and now seems to lead to the .py files.

(Figure.savefig() does not accept a Path object as fname, but thats not really this issue.)

alkatar21 avatar Sep 14 '22 14:09 alkatar21

Can you try pylance pre-release?

I think I has a newer version of the matplot stubs

bschnurr avatar Sep 14 '22 18:09 bschnurr

@bschnurr, this still repros in 2022.9.11. Strangely go to definition on plt.Axes takes me to the Axes class. Given that, I'm not sure what the "Axes" is not a known member of module error is all about.

debonte avatar Sep 14 '22 19:09 debonte

Can you try pylance pre-release?

I think I has a newer version of the matplot stubs

I have tried that. It is the same in all versions I think.

alkatar21 avatar Sep 14 '22 19:09 alkatar21

@bschnurr, this still repros in 2022.9.11. Strangely go to definition on plt.Axes takes me to the Axes class. Given that, I'm not sure what the "Axes" is not a known member of module error is all about.

Yes, I have noticed this more often lately in various other places, but haven't found the time to get to the bottom of it yet. If you use matplotlib.axes.Axes the autocompletion for the functions also works, although it is not found afterwards. It feels like there are 2 different parts.

alkatar21 avatar Sep 14 '22 19:09 alkatar21

lowercase axes is also suspect. from matplotlib import pyplot as plt, axes

i'll take a look

bschnurr avatar Sep 14 '22 20:09 bschnurr