[ENH]: More accurate type stub for plt.subplots
like VSCode did before.
#28226
Labels
plt.subplots
like VSCode did before.
#28226
Problem
Before matplotlib 3.8, VSCode embedded its type stubs for matplotlib. At that time, the typehint of
plt.subplots
is better than the typehint provided by matplotlib itself. You can see the differences below:Let's see the embedded typehint for plt.subplots. I made it available by changing the Matplotlib version to 3.7. It can identify the
ax
type correctly.However, after upgrading to matplotlib 3.8. The VSCode use the type stub provided by matplotlib instead of the one embedded by itself. And it cannot get the corrent type for
ax
.Proposed solution
Adapt the type stub provided by VSCode. You can see them in https://github.com/microsoft/python-type-stubs/blob/102c1448f7504d6450a221ae9c29a260fa741a30/matplotlib/pyplot.pyi#L200C1-L209C30.
I tried just putting the
pyplot.pyi
file in thepyplot.py
folder. It works. So maybe we can do it in repo.The text was updated successfully, but these errors were encountered: