Skip to content

Commit 65ba01b

Browse files
committed
Enable linting of .pyi files
1 parent a30354e commit 65ba01b

32 files changed

+305
-122
lines changed

lib/matplotlib/__init__.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ __all__ = [
2626
"interactive",
2727
"is_interactive",
2828
"colormaps",
29+
"multivar_colormaps",
30+
"bivar_colormaps",
2931
"color_sequences",
3032
]
3133

lib/matplotlib/_enums.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from typing import cast
21
from enum import Enum
32

43

lib/matplotlib/_path.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ import numpy as np
55
from .transforms import BboxBase
66

77
def affine_transform(points: np.ndarray, trans: np.ndarray) -> np.ndarray: ...
8-
def count_bboxes_overlapping_bbox(bbox: BboxBase, bboxes: Sequence[BboxBase]) -> int: ...
8+
def count_bboxes_overlapping_bbox(
9+
bbox: BboxBase, bboxes: Sequence[BboxBase]
10+
) -> int: ...

lib/matplotlib/_tri.pyi

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import numpy.typing as npt
77
@final
88
class TrapezoidMapTriFinder:
99
def __init__(self, triangulation: Triangulation): ...
10-
def find_many(self, x: npt.NDArray[np.float64], y: npt.NDArray[np.float64]) -> npt.NDArray[np.int_]: ...
10+
def find_many(
11+
self, x: npt.NDArray[np.float64], y: npt.NDArray[np.float64]
12+
) -> npt.NDArray[np.int_]: ...
1113
def get_tree_stats(self) -> list[int | float]: ...
1214
def initialize(self) -> None: ...
1315
def print_tree(self) -> None: ...
@@ -16,7 +18,9 @@ class TrapezoidMapTriFinder:
1618
class TriContourGenerator:
1719
def __init__(self, triangulation: Triangulation, z: npt.NDArray[np.float64]): ...
1820
def create_contour(self, level: float) -> tuple[list[float], list[int]]: ...
19-
def create_filled_contour(self, lower_level: float, upper_level: float) -> tuple[list[float], list[int]]: ...
21+
def create_filled_contour(
22+
self, lower_level: float, upper_level: float
23+
) -> tuple[list[float], list[int]]: ...
2024

2125
@final
2226
class Triangulation:
@@ -30,7 +34,9 @@ class Triangulation:
3034
neighbors: npt.NDArray[np.int_] | tuple[()],
3135
correct_triangle_orientation: bool,
3236
): ...
33-
def calculate_plane_coefficients(self, z: npt.ArrayLike) -> npt.NDArray[np.float64]: ...
37+
def calculate_plane_coefficients(
38+
self, z: npt.ArrayLike
39+
) -> npt.NDArray[np.float64]: ...
3440
def get_edges(self) -> npt.NDArray[np.int_]: ...
3541
def get_neighbors(self) -> npt.NDArray[np.int_]: ...
3642
def set_mask(self, mask: npt.NDArray[np.bool_] | tuple[()]) -> None: ...

lib/matplotlib/animation.pyi

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ class AbstractMovieWriter(abc.ABC, metaclass=abc.ABCMeta):
4141
dpi: float
4242

4343
@abc.abstractmethod
44-
def setup(self, fig: Figure, outfile: str | Path, dpi: float | None = ...) -> None: ...
44+
def setup(
45+
self, fig: Figure, outfile: str | Path, dpi: float | None = ...
46+
) -> None: ...
4547
@property
4648
def frame_size(self) -> tuple[int, int]: ...
4749
@abc.abstractmethod
@@ -65,7 +67,9 @@ class MovieWriter(AbstractMovieWriter):
6567
extra_args: list[str] | None = ...,
6668
metadata: dict[str, str] | None = ...,
6769
) -> None: ...
68-
def setup(self, fig: Figure, outfile: str | Path, dpi: float | None = ...) -> None: ...
70+
def setup(
71+
self, fig: Figure, outfile: str | Path, dpi: float | None = ...
72+
) -> None: ...
6973
def grab_frame(self, **savefig_kwargs) -> None: ...
7074
def finish(self) -> None: ...
7175
@classmethod
@@ -200,7 +204,9 @@ class TimedAnimation(Animation):
200204
) -> None: ...
201205

202206
class ArtistAnimation(TimedAnimation):
203-
def __init__(self, fig: Figure, artists: Sequence[Collection[Artist]], *args, **kwargs) -> None: ...
207+
def __init__(
208+
self, fig: Figure, artists: Sequence[Collection[Artist]], *args, **kwargs
209+
) -> None: ...
204210

205211
class FuncAnimation(TimedAnimation):
206212
def __init__(

lib/matplotlib/artist.pyi

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,14 @@ class Artist:
114114
def set_clip_on(self, b: bool) -> None: ...
115115
def get_rasterized(self) -> bool: ...
116116
def set_rasterized(self, rasterized: bool) -> None: ...
117-
def get_agg_filter(self) -> Callable[[ArrayLike, float], tuple[np.ndarray, float, float]] | None: ...
117+
def get_agg_filter(self) -> Callable[
118+
[ArrayLike, float], tuple[np.ndarray, float, float]
119+
] | None: ...
118120
def set_agg_filter(
119-
self, filter_func: Callable[[ArrayLike, float], tuple[np.ndarray, float, float]] | None
121+
self,
122+
filter_func: Callable[
123+
[ArrayLike, float], tuple[np.ndarray, float, float]
124+
] | None
120125
) -> None: ...
121126
def draw(self, renderer: RendererBase) -> None: ...
122127
def set_alpha(self, alpha: float | None) -> None: ...
@@ -193,5 +198,7 @@ def getp(obj: Artist, property: str | None = ...) -> Any: ...
193198

194199
get = getp
195200

196-
def setp(obj: Artist, *args, file: TextIO | None = ..., **kwargs) -> list[Any] | None: ...
201+
def setp(
202+
obj: Artist, *args, file: TextIO | None = ..., **kwargs
203+
) -> list[Any] | None: ...
197204
def kwdoc(artist: Artist | type[Artist] | Iterable[Artist | type[Artist]]) -> str: ...

lib/matplotlib/axes/_axes.pyi

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ from matplotlib.axes._base import _AxesBase
22
from matplotlib.axes._secondary_axes import SecondaryAxis
33

44
from matplotlib.artist import Artist
5-
from matplotlib.backend_bases import RendererBase
65
from matplotlib.collections import (
76
Collection,
87
FillBetweenPolyCollection,
@@ -32,7 +31,6 @@ import matplotlib.table as mtable
3231
import matplotlib.stackplot as mstack
3332
import matplotlib.streamplot as mstream
3433

35-
import datetime
3634
import PIL.Image
3735
from collections.abc import Callable, Iterable, Sequence
3836
from typing import Any, Literal, overload
@@ -60,9 +58,16 @@ class Axes(_AxesBase):
6058
@overload
6159
def legend(self) -> Legend: ...
6260
@overload
63-
def legend(self, handles: Iterable[Artist | tuple[Artist, ...]], labels: Iterable[str], **kwargs) -> Legend: ...
61+
def legend(
62+
self,
63+
handles: Iterable[Artist | tuple[Artist, ...]],
64+
labels: Iterable[str],
65+
**kwargs
66+
) -> Legend: ...
6467
@overload
65-
def legend(self, *, handles: Iterable[Artist | tuple[Artist, ...]], **kwargs) -> Legend: ...
68+
def legend(
69+
self, *, handles: Iterable[Artist | tuple[Artist, ...]], **kwargs
70+
) -> Legend: ...
6671
@overload
6772
def legend(self, labels: Iterable[str], **kwargs) -> Legend: ...
6873
@overload
@@ -401,7 +406,8 @@ class Axes(_AxesBase):
401406
vmax: float | None = ...,
402407
alpha: float | None = ...,
403408
linewidths: float | Sequence[float] | None = ...,
404-
edgecolors: Literal["face", "none"] | ColorType | Sequence[ColorType] | None = ...,
409+
edgecolors: Literal["face", "none"] | ColorType | Sequence[ColorType] | None =
410+
...,
405411
colorizer: Colorizer | None = ...,
406412
plotnonfinite: bool = ...,
407413
data=...,

lib/matplotlib/axes/_base.pyi

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,9 @@ class _AxesBase(martist.Artist):
367367
def get_navigate(self) -> bool: ...
368368
def set_navigate(self, b: bool) -> None: ...
369369
def get_forward_navigation_events(self) -> bool | Literal["auto"]: ...
370-
def set_forward_navigation_events(self, forward: bool | Literal["auto"]) -> None: ...
370+
def set_forward_navigation_events(
371+
self, forward: bool | Literal["auto"]
372+
) -> None: ...
371373
def get_navigate_mode(self) -> Literal["PAN", "ZOOM"] | None: ...
372374
def set_navigate_mode(self, b: Literal["PAN", "ZOOM"] | None) -> None: ...
373375
def start_pan(self, x: float, y: float, button: MouseButton) -> None: ...
@@ -393,9 +395,10 @@ class _AxesBase(martist.Artist):
393395
def label_outer(self, remove_inner_ticks: bool = ...) -> None: ...
394396

395397
# The methods underneath this line are added via the `_axis_method_wrapper` class
396-
# Initially they are set to an object, but that object uses `__set_name__` to override
397-
# itself with a method modified from the Axis methods for the x or y Axis.
398-
# As such, they are typed according to the resultant method rather than as that object.
398+
# Initially they are set to an object, but that object uses `__set_name__` to
399+
# override itself with a method modified from the Axis methods for the x or y Axis.
400+
# As such, they are typed according to the resultant method rather than as
401+
# that object.
399402

400403
def get_xgridlines(self) -> list[Line2D]: ...
401404
def get_xticklines(self, minor: bool = ...) -> list[Line2D]: ...

lib/matplotlib/axes/_secondary_axes.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ class SecondaryAxis(_AxesBase):
3939
) -> list[Tick]: ...
4040
def set_functions(
4141
self,
42-
functions: tuple[Callable[[ArrayLike], ArrayLike], Callable[[ArrayLike], ArrayLike]] | Transform,
42+
functions: tuple[
43+
Callable[[ArrayLike], ArrayLike], Callable[[ArrayLike], ArrayLike]
44+
] | Transform,
4345
) -> None: ...
4446
def set_aspect(self, *args, **kwargs) -> None: ...
4547
def set_color(self, color: ColorType) -> None: ...

lib/matplotlib/backend_bases.pyi

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class RendererBase:
106106
prop: FontProperties,
107107
angle: float,
108108
*,
109-
mtext: Text | None = ...
109+
mtext: Text | None = ...,
110110
) -> None: ...
111111
def draw_text(
112112
self,
@@ -275,7 +275,7 @@ class PickEvent(Event):
275275
mouseevent: MouseEvent,
276276
artist: Artist,
277277
guiEvent: Any | None = ...,
278-
**kwargs
278+
**kwargs,
279279
) -> None: ...
280280

281281
class KeyEvent(LocationEvent):
@@ -344,7 +344,7 @@ class FigureCanvasBase:
344344
pad_inches: float | None = ...,
345345
bbox_extra_artists: list[Artist] | None = ...,
346346
backend: str | None = ...,
347-
**kwargs
347+
**kwargs,
348348
) -> Any: ...
349349
@classmethod
350350
def get_default_filetype(cls) -> str: ...
@@ -366,23 +366,24 @@ class FigureCanvasBase:
366366
],
367367
func: Callable[[MouseEvent], Any],
368368
) -> int: ...
369-
370369
@overload
371370
def mpl_connect(
372371
self,
373372
s: Literal["key_press_event", "key_release_event"],
374373
func: Callable[[KeyEvent], Any],
375374
) -> int: ...
376-
377375
@overload
378-
def mpl_connect(self, s: Literal["pick_event"], func: Callable[[PickEvent], Any]) -> int: ...
379-
376+
def mpl_connect(
377+
self, s: Literal["pick_event"], func: Callable[[PickEvent], Any]
378+
) -> int: ...
380379
@overload
381-
def mpl_connect(self, s: Literal["resize_event"], func: Callable[[ResizeEvent], Any]) -> int: ...
382-
380+
def mpl_connect(
381+
self, s: Literal["resize_event"], func: Callable[[ResizeEvent], Any]
382+
) -> int: ...
383383
@overload
384-
def mpl_connect(self, s: Literal["close_event"], func: Callable[[CloseEvent], Any]) -> int: ...
385-
384+
def mpl_connect(
385+
self, s: Literal["close_event"], func: Callable[[CloseEvent], Any]
386+
) -> int: ...
386387
@overload
387388
def mpl_connect(self, s: str, func: Callable[[Event], Any]) -> int: ...
388389
def mpl_disconnect(self, cid: int) -> None: ...
@@ -459,6 +460,7 @@ class NavigationToolbar2:
459460
button: MouseButton
460461
axes: list[Axes]
461462
cid: int
463+
462464
def press_pan(self, event: Event) -> None: ...
463465
def drag_pan(self, event: Event) -> None: ...
464466
def release_pan(self, event: Event) -> None: ...
@@ -470,6 +472,7 @@ class NavigationToolbar2:
470472
axes: list[Axes]
471473
cid: int
472474
cbar: Colorbar
475+
473476
def press_zoom(self, event: Event) -> None: ...
474477
def drag_zoom(self, event: Event) -> None: ...
475478
def release_zoom(self, event: Event) -> None: ...
@@ -504,9 +507,13 @@ class _Backend:
504507
FigureManager: type[FigureManagerBase]
505508
mainloop: None | Callable[[], Any]
506509
@classmethod
507-
def new_figure_manager(cls, num: int | str, *args, **kwargs) -> FigureManagerBase: ...
510+
def new_figure_manager(
511+
cls, num: int | str, *args, **kwargs
512+
) -> FigureManagerBase: ...
508513
@classmethod
509-
def new_figure_manager_given_figure(cls, num: int | str, figure: Figure) -> FigureManagerBase: ...
514+
def new_figure_manager_given_figure(
515+
cls, num: int | str, figure: Figure
516+
) -> FigureManagerBase: ...
510517
@classmethod
511518
def draw_if_interactive(cls) -> None: ...
512519
@classmethod

lib/matplotlib/backend_tools.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,6 @@ default_toolbar_tools: list[list[str | list[str]]]
118118
def add_tools_to_manager(
119119
toolmanager: ToolManager, tools: dict[str, type[ToolBase]] = ...
120120
) -> None: ...
121-
def add_tools_to_container(container: ToolContainerBase, tools: list[Any] = ...) -> None: ...
121+
def add_tools_to_container(
122+
container: ToolContainerBase, tools: list[Any] = ...
123+
) -> None: ...

lib/matplotlib/backends/registry.pyi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
from enum import Enum
22
from types import ModuleType
33

4-
54
class BackendFilter(Enum):
65
INTERACTIVE = 0
76
NON_INTERACTIVE = 1
87

9-
108
class BackendRegistry:
119
_BUILTIN_BACKEND_TO_GUI_FRAMEWORK: dict[str, str]
1210
_GUI_FRAMEWORK_TO_BACKEND: dict[str, str]
@@ -20,16 +18,18 @@ class BackendRegistry:
2018
def _ensure_entry_points_loaded(self) -> None: ...
2119
def _get_gui_framework_by_loading(self, backend: str) -> str: ...
2220
def _read_entry_points(self) -> list[tuple[str, str]]: ...
23-
def _validate_and_store_entry_points(self, entries: list[tuple[str, str]]) -> None: ...
24-
21+
def _validate_and_store_entry_points(
22+
self, entries: list[tuple[str, str]]
23+
) -> None: ...
2524
def backend_for_gui_framework(self, framework: str) -> str | None: ...
2625
def is_valid_backend(self, backend: str) -> bool: ...
2726
def list_all(self) -> list[str]: ...
2827
def list_builtin(self, filter_: BackendFilter | None) -> list[str]: ...
2928
def list_gui_frameworks(self) -> list[str]: ...
3029
def load_backend_module(self, backend: str) -> ModuleType: ...
3130
def resolve_backend(self, backend: str | None) -> tuple[str, str | None]: ...
32-
def resolve_gui_or_backend(self, gui_or_backend: str | None) -> tuple[str, str | None]: ...
33-
31+
def resolve_gui_or_backend(
32+
self, gui_or_backend: str | None
33+
) -> tuple[str, str | None]: ...
3434

3535
backend_registry: BackendRegistry

lib/matplotlib/cbook.pyi

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ class GrouperView(Generic[_T]):
118118

119119
def simple_linear_interpolation(a: ArrayLike, steps: int) -> np.ndarray: ...
120120
def delete_masked_points(*args): ...
121-
def _broadcast_with_masks(*args: ArrayLike, compress: bool = ...) -> list[ArrayLike]: ...
121+
def _broadcast_with_masks(
122+
*args: ArrayLike, compress: bool = ...
123+
) -> list[ArrayLike]: ...
122124
def boxplot_stats(
123125
X: ArrayLike,
124126
whis: float | tuple[float, float] = ...,
@@ -154,7 +156,9 @@ def _str_equal(obj: Any, s: str) -> bool: ...
154156
def _str_lower_equal(obj: Any, s: str) -> bool: ...
155157
def _array_perimeter(arr: np.ndarray) -> np.ndarray: ...
156158
def _unfold(arr: np.ndarray, axis: int, size: int, step: int) -> np.ndarray: ...
157-
def _array_patch_perimeters(x: np.ndarray, rstride: int, cstride: int) -> np.ndarray: ...
159+
def _array_patch_perimeters(
160+
x: np.ndarray, rstride: int, cstride: int
161+
) -> np.ndarray: ...
158162
def _setattr_cm(obj: Any, **kwargs) -> contextlib.AbstractContextManager[None]: ...
159163

160164
class _OrderedSet(collections.abc.MutableSet):

lib/matplotlib/cm.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ _colormaps: ColormapRegistry = ...
1919
_multivar_colormaps: ColormapRegistry = ...
2020
_bivar_colormaps: ColormapRegistry = ...
2121

22-
def get_cmap(name: str | colors.Colormap | None = ..., lut: int | None = ...) -> colors.Colormap: ...
22+
def get_cmap(
23+
name: str | colors.Colormap | None = ..., lut: int | None = ...
24+
) -> colors.Colormap: ...
2325

2426
ScalarMappable = _ScalarMappable

lib/matplotlib/collections.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ class LineCollection(Collection):
157157
def get_segments(self) -> list[np.ndarray]: ...
158158
def set_color(self, c: ColorType | Sequence[ColorType]) -> None: ...
159159
def set_colors(self, c: ColorType | Sequence[ColorType]) -> None: ...
160-
def set_gapcolor(self, gapcolor: ColorType | Sequence[ColorType] | None) -> None: ...
160+
def set_gapcolor(
161+
self, gapcolor: ColorType | Sequence[ColorType] | None
162+
) -> None: ...
161163
def get_color(self) -> ColorType | Sequence[ColorType]: ...
162164
def get_colors(self) -> ColorType | Sequence[ColorType]: ...
163165
def get_gapcolor(self) -> ColorType | Sequence[ColorType] | None: ...

0 commit comments

Comments
 (0)