Skip to content

Enable linting of .pyi files #30006

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

Merged
merged 1 commit into from
May 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/matplotlib/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ __all__ = [
"interactive",
"is_interactive",
"colormaps",
"multivar_colormaps",
"bivar_colormaps",
"color_sequences",
]

Expand Down
1 change: 0 additions & 1 deletion lib/matplotlib/_enums.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from typing import cast
from enum import Enum


Expand Down
2 changes: 0 additions & 2 deletions lib/matplotlib/axes/_axes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ from matplotlib.axes._base import _AxesBase
from matplotlib.axes._secondary_axes import SecondaryAxis

from matplotlib.artist import Artist
from matplotlib.backend_bases import RendererBase
from matplotlib.collections import (
Collection,
FillBetweenPolyCollection,
Expand Down Expand Up @@ -32,7 +31,6 @@ import matplotlib.table as mtable
import matplotlib.stackplot as mstack
import matplotlib.streamplot as mstream

import datetime
import PIL.Image
from collections.abc import Callable, Iterable, Sequence
from typing import Any, Literal, overload
Expand Down
1 change: 0 additions & 1 deletion lib/matplotlib/colorizer.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from matplotlib import cbook, colorbar, colors, artist

from typing import overload
import numpy as np
from numpy.typing import ArrayLike

Expand Down
8 changes: 4 additions & 4 deletions lib/matplotlib/colors.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ class BivarColormap:
M: int
n_variates: int
def __init__(
self, N: int = ..., M: int | None = ..., shape: Literal['square', 'circle', 'ignore', 'circleignore'] = ...,
origin: Sequence[float] = ..., name: str = ...
self, N: int = ..., M: int | None = ..., shape: Literal['square', 'circle', 'ignore', 'circleignore'] = ...,
origin: Sequence[float] = ..., name: str = ...
) -> None: ...
@overload
def __call__(
Expand Down Expand Up @@ -245,8 +245,8 @@ class SegmentedBivarColormap(BivarColormap):

class BivarColormapFromImage(BivarColormap):
def __init__(
self, lut: np.ndarray, shape: Literal['square', 'circle', 'ignore', 'circleignore'] = ...,
origin: Sequence[float] = ..., name: str = ...
self, lut: np.ndarray, shape: Literal['square', 'circle', 'ignore', 'circleignore'] = ...,
origin: Sequence[float] = ..., name: str = ...
) -> None: ...

class Normalize:
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/contour.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import matplotlib.cm as cm
from matplotlib.artist import Artist
from matplotlib.axes import Axes
from matplotlib.collections import Collection, PathCollection
from matplotlib.collections import Collection
from matplotlib.colorizer import Colorizer, ColorizingArtist
from matplotlib.colors import Colormap, Normalize
from matplotlib.path import Path
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/table.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ from .transforms import Bbox
from .typing import ColorType

from collections.abc import Sequence
from typing import Any, Literal, TYPE_CHECKING
from typing import Any, Literal

from pandas import DataFrame

Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/text.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ from .transforms import (
Transform,
)

from collections.abc import Callable, Iterable
from collections.abc import Iterable
from typing import Any, Literal
from .typing import ColorType, CoordsType

Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ exclude = [
"tools/gh_api.py",
".tox",
".eggs",
# TODO: fix .pyi files
"*.pyi",
# TODO: fix .ipynb files
"*.ipynb"
]
Expand Down Expand Up @@ -173,6 +171,7 @@ external = [
convention = "numpy"

[tool.ruff.lint.per-file-ignores]
"*.pyi" = ["E501"]
"doc/conf.py" = ["E402"]
"galleries/examples/animation/frame_grabbing_sgskip.py" = ["E402"]
"galleries/examples/images_contours_and_fields/tricontour_demo.py" = ["E201"]
Expand Down
Loading