8000 [Bug]: Type checkers not finding `Axes`, `Figure` in `matplotlib.pyplot` · Issue #26812 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
[Bug]: Type checkers not finding Axes, Figure in matplotlib.pyplot #26812
Closed as not planned
@Dr-Irv

Description

@Dr-Irv

Bug summary

We had code that did imports of Axes and Figure as follows:

This used to work fine with type checkers like pyright and mypy prior to matplotlib 3.8. Now the type checkers complain.

Code for reproduction

from matplotlib import pyplot as plt
plt.Axes
plt.Figure

Actual outcome

pyright reports that Axes and Figure are not exported from the module pyplot

Expected outcome

No typing error.

Additional information

Fix would be to do something like this in pyplot.py

from matplotlib.axes import Axes as Axes
from matploblib.figure import Figure as Figure

This came up due to our CI for pandas-stubs that was testing typing of pandas against matplotlib imports

Operating system

Windows 10

Matplotlib Version

3.8

Matplotlib Backend

N/A

Python version

3.10

Jupyter version

N/A

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0