Skip to content

Support type checking with mypy #20504

Closed

Description

@rggjan

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

Activity

  1. story645 commented on Jun 24, 2021

    @story645
    Member
  2. jklymak commented on Jun 24, 2021

    @jklymak
    Member

    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.

  3. rggjan commented on Jun 28, 2021

    @rggjan
    Author

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

  4. rggjan commented on Jun 28, 2021

    @rggjan
    Author

    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.

  5. added this to the milestone on Jun 28, 2021
  6. modified the milestones: , needs sorting on Oct 6, 2022
  7. tmke8 commented on Dec 1, 2022

    @tmke8

    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

  8. Dr-Irv commented on Jan 9, 2023

    @Dr-Irv

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions