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
{{ message }}
Repository navigation
[ENH]: More accurate type stub for plt.subplots like VSCode did before. #28226
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.
changed the title [-][ENH]: More accurate type stub for `plts.subplots` like VSCode did before.[/-][+][ENH]: More accurate type stub for `plt.subplots` like VSCode did before.[/+]on May 15, 2024
The short version is "its complicated" and, while we can do better the perfect behavior is not super possible, since this method returns different types based on the value of parameters. Any is a shortcut for "at least it won't yell at users here".
Activity
[-][ENH]: More accurate type stub for `plts.subplots` like VSCode did before.[/-][+][ENH]: More accurate type stub for `plt.subplots` like VSCode did before.[/+]ksunden commentedon May 15, 2024
The short version is "its complicated" and, while we can do better the perfect behavior is not super possible, since this method returns different types based on the value of parameters. Any is a shortcut for "at least it won't yell at users here".
Closing as a duplicate of #28210 and #27025
See also #27001, which is a PR to improve this type hint, and includes a discussion of why the VSCode version is actually incorrect.