Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Support type checking with mypy #20504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rggjan opened this issue Jun 24, 2021 · 7 comments · Fixed by #24976
Closed

Support type checking with mypy #20504

rggjan opened this issue Jun 24, 2021 · 7 comments · Fixed by #24976

Comments

@rggjan
Copy link

rggjan commented Jun 24, 2021

Would be great if matplotlib added type information and support for type checking with mypy, for example...

@story645
Copy link
Member

xref: #17991, #13798, #15926

@jklymak
Copy link
Member

jklymak commented Jun 24, 2021

As discussed on the call, Matplotlib may reconsider this after numpy has been through type hinting for a couple of releases.

In the meantime, if anyone wants to release a separate package that supplies the hinting stubs, matplotlib would be be happy to support, perhaps even on the matplotlib root project (i.e. matplotlib/mpl-hinting) once it was shown to be generally useful.

We will keep this open to track conversation.

@rggjan
Copy link
Author

rggjan commented Jun 28, 2021

Sorry, didn't find the other issues, probably since I was only searching for mypy...

@rggjan
Copy link
Author

rggjan commented Jun 28, 2021

Maybe some of this could be taken over:
Mypy type stubs for NumPy, pandas, and Matplotlib
?

It has the note:

⚠️ this project has mostly stopped development ⚠️

The pandas team and the numpy team are both in the process of integrating type stubs into their codebases, and we don't see the point of competing with them.

@tmke8
Copy link

tmke8 commented Dec 1, 2022

The Pylance team at Microsoft seems to have produced pretty good type stubs for matplotlib: https://github.com/microsoft/python-type-stubs/tree/main/matplotlib

@Dr-Irv
Copy link

Dr-Irv commented Jan 9, 2023

The Pylance team at Microsoft seems to have produced pretty good type stubs for matplotlib: https://github.com/microsoft/python-type-stubs/tree/main/matplotlib

With pandas, we created a pandas-stubs project https://github.com/pandas-dev/pandas-stubs that evolved as follows:

  1. We started with the stubs that Microsoft was maintaining as part of https://github.com/microsoft/python-type-stubs/
  2. In that project, we merged in tests from https://github.com/VirtusLab/pandas-stubs to provide a testing framework for the stubs.
  3. We met with the leader of the Microsoft project and VirtusLabs and agreed that the pandas team would start supplying the stubs, that the pandas stubs would be removed from the Microsoft project, and that VirtusLabs would deprecate their stubs.
  4. The pylance team now bundles the "official" pandas-stubs with pylance.

I would suggest a similar path for matplotlib. Create a matplotlib-stubs project, and work with Microsoft to use their stubs as a starting point. You might also consider looking at what we are doing in pandas-stubs to create a testing methodology for correctness of the stubs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants