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

Skip to content

Commit 0c85211

Browse files
committed
Insert the majority of the pyi stub files
Transforms pyi, remove hints from transforms.py, minimal required _path.pyi for imports Type stubs for artists.pyi bezier and hatch pyi files gridspec pyi A few extra hints/import axis.pyi file scale.pyi style public api type stubs Fix up style typehints (remove redundant pyi for __init__, add/fix core) Lines pyi Triangulation type hints backend tools stubs projections stubs Backend bases/managers pyis, move some shared types Missing imports container.pyi layout_engine.pyi Ticker, including updating polar mlab.pyi relax type hint on FuncFormatter callable dviread.pyi animation.pyi collections.pyi rcsetup.pyi mathtext.pyi figure.pyi and associated changes fuller ft2font stackplot pyi spelling markers.pyi image.pyi font_manager path effects, spines texmanager, text pyi files Some additional modifications for consistency cbook, textpath pyi colorbar, sankey pyi path pyi quiver pyi widgets pyi contour pyi Colors, cm pyi stubs offsetbox, table pyi stubs streamplot type stubs legend and legendhandler stubs patches type stubs _enums pyi, ignores setting attr after instantiation Axes except AxesBase type stubs Axes Base and associated updates to type stubs _format_approx stub and igonore setattr in mathtext Add some type ignores and fix some imports more type ignores for mpl_toolkits Finish typing Axes Remove TypeAlias since its newer than py3.8 missing/incorrect axes and figure annotations Corrections and private method annotations used in pyplot
1 parent 4382054 commit 0c85211

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+5848
-15
lines changed

lib/matplotlib/_enums.pyi

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from enum import Enum
2+
3+
class _AutoStringNameEnum(Enum):
4+
def __hash__(self): ...
5+
6+
class JoinStyle(str, _AutoStringNameEnum):
7+
miter: str
8+
round: str
9+
bevel: str
10+
@staticmethod
11+
def demo() -> None: ...
12+
13+
class CapStyle(str, _AutoStringNameEnum):
14+
butt: str
15+
projecting: str
16+
round: str
17+
@staticmethod
18+
def demo() -> None: ...

lib/matplotlib/_mathtext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1333,7 +1333,7 @@ def __init__(self, state):
13331333

13341334
_GlueSpec = namedtuple(
13351335
"_GlueSpec", "width stretch stretch_order shrink shrink_order")
1336-
_GlueSpec._named = {
1336+
_GlueSpec._named = { # type: ignore[attr-defined]
13371337
'fil': _GlueSpec(0., 1., 1, 0., 0),
13381338
'fill': _GlueSpec(0., 1., 2, 0., 0),
13391339
'filll': _GlueSpec(0., 1., 3, 0., 0),

lib/matplotlib/_path.pyi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from typing import Sequence
2+
import numpy as np
3+
from .transforms import BboxBase
4+
5+
6+
def affine_transform(points: np.ndarray, matrix: np.ndarray) -> np.ndarray: ...
7+
def count_bboxes_overlapping_bbox(a: BboxBase, bboxes: Sequence[BboxBase]) -> int: ...
8+
def update_path_extents(*args, **kwargs): ...

lib/matplotlib/_pylab_helpers.pyi

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from collections import OrderedDict
2+
3+
from matplotlib.backend_bases import FigureManagerBase
4+
from matplotlib.figure import Figure
5+
6+
class Gcf:
7+
figs: OrderedDict[int, FigureManagerBase]
8+
@classmethod
9+
def get_fig_manager(cls, num: int) -> FigureManagerBase: ...
10+
@classmethod
11+
def destroy(cls, num: int | FigureManagerBase) -> None: ...
12+
@classmethod
13+
def destroy_fig(cls, fig: Figure) -> None: ...
14+
@classmethod
15+
def destroy_all(cls) -> None: ...
16+
@classmethod
17+
def has_fignum(cls, num: int) -> bool: ...
18+
@classmethod
19+
def get_all_fig_managers(cls) -> list[FigureManagerBase]: ...
20+
@classmethod
21+
def get_num_fig_managers(cls) -> int: ...
22+
@classmethod
23+
def get_active(cls) -> FigureManagerBase: ...
24+
@classmethod
25+
def set_active(cls, manager: FigureManagerBase) -> None: ...
26+
@classmethod
27+
def draw_all(cls, force: bool = ...) -> None: ...

lib/matplotlib/_tri.pyi

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# This is a private module implemented in C++
2+
# As such these type stubs are overly generic, but here to allow these types
3+
# as return types for public methods
4+
from typing import Any
5+
6+
class TrapezoidMapTriFinder:
7+
def __init__(self, *args, **kwargs) -> None: ...
8+
def find_many(self, *args, **kwargs) -> Any: ...
9+
def get_tree_stats(self, *args, **kwargs) -> Any: ...
10+
def initialize(self, *args, **kwargs) -> Any: ...
11+
def print_tree(self, *args, **kwargs) -> Any: ...
12+
13+
class TriContourGenerator:
14+
def __init__(self, *args, **kwargs) -> None: ...
15+
def create_contour(self, *args, **kwargs) -> Any: ...
16+
def create_filled_contour(self, *args, **kwargs) -> Any: ...
17+
18+
class Triangulation:
19+
def __init__(self, *args, **kwargs) -> None: ...
20+
def calculate_plane_coefficients(self, *args, **kwargs) -> Any: ...
21+
def get_edges(self, *args, **kwargs) -> Any: ...
22+
def get_neighbors(self, *args, **kwargs) -> Any: ...
23+
def set_mask(self, *args, **kwargs) -> Any: ...

lib/matplotlib/animation.pyi

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
import abc
2+
from collections.abc import Generator
3+
import contextlib
4+
from pathlib import Path
5+
from matplotlib import cbook
6+
from matplotlib._animation_data import DISPLAY_TEMPLATE, INCLUDED_FRAMES, JS_INCLUDE, STYLE_INCLUDE
7+
from matplotlib.artist import Artist
8+
from matplotlib.backend_bases import TimerBase
9+
from matplotlib.figure import Figure
10+
11+
from typing import Any, Callable, Iterable, Generator, Type
12+
13+
subprocess_creation_flags: int
14+
15+
def adjusted_figsize(w: float, h: float, dpi: float, n: int) -> tuple[float, float]: ...
16+
17+
class MovieWriterRegistry:
18+
def __init__(self) -> None: ...
19+
def register(self, name: str) -> Callable[[Type[AbstractMovieWriter]], Type[AbstractMovieWriter]]: ...
20+
def is_available(self, name: str) -> bool: ...
21+
def __iter__(self) -> Generator[str, None, None]: ...
22+
def list(self) -> list[str]: ...
23+
def __getitem__(self, name: str) -> Type[AbstractMovieWriter]: ...
24+
25+
writers: MovieWriterRegistry
26+
27+
class AbstractMovieWriter(abc.ABC, metaclass=abc.ABCMeta):
28+
fps: int
29+
metadata: dict[str, str]
30+
codec: str
31+
bitrate: int
32+
def __init__(self, fps: int = ..., metadata: dict[str, str] | None = ..., codec: str | None = ..., bitrate: int | None = ...) -> None: ...
33+
outfile: str | Path
34+
fig: Figure
35+
dpi: float
36+
37+
@abc.abstractmethod
38+
def setup(self, fig: Figure, outfile: str | Path, dpi: float | None = ...): ...
39+
@property
40+
def frame_size(self) -> tuple[int, int]: ...
41+
@abc.abstractmethod
42+
def grab_frame(self, **savefig_kwargs) -> None: ...
43+
@abc.abstractmethod
44+
def finish(self) -> None: ...
45+
46+
@contextlib.contextmanager
47+
def saving(self, fig: Figure, outfile: str | Path, dpi: float | None, *args, **kwargs) -> Generator[AbstractMovieWriter, None, None]: ...
48+
49+
class MovieWriter(AbstractMovieWriter):
50+
supported_formats: list[str]
51+
frame_format: str
52+
extra_args: list[str] | None
53+
def __init__(self, fps: int = ..., codec: str | None = ..., bitrate: int | None = ..., extra_args: list[str] | None = ..., metadata: dict[str, str] | None = ...) -> None: ...
54+
def setup(self, fig: Figure, outfile: str | Path, dpi: float | None = ...): ...
55+
def grab_frame(self, **savefig_kwargs) -> None: ...
56+
def finish(self) -> None: ...
57+
@classmethod
58+
def bin_path(cls) -> str: ...
59+
@classmethod
60+
def isAvailable(cls) -> bool: ...
61+
62+
class FileMovieWriter(MovieWriter):
63+
fig: Figure
64+
outfile: str | Path
65+
dpi: float
66+
temp_prefix: str
67+
fname_format_str: str
68+
def setup(self, fig: Figure, outfile: str | Path, dpi: float | None = ..., frame_prefix: str | Path | None = ...) -> None: ...
69+
def __del__(self) -> None: ...
70+
@property
71+
def frame_format(self) -> str: ...
72+
@frame_format.setter
73+
def frame_format(self, frame_format: str) -> None: ...
74+
75+
class PillowWriter(AbstractMovieWriter):
76+
@classmethod
77+
def isAvailable(cls) -> bool: ...
78+
def setup(self, fig: Figure, outfile: str | Path, dpi: float | None = ...) -> None: ...
79+
def grab_frame(self, **savefig_kwargs) -> None: ...
80+
def finish(self) -> None: ...
81+
82+
class FFMpegBase:
83+
codec: str
84+
@property
85+
def output_args(self) -> list[str]: ...
86+
87+
class FFMpegWriter(FFMpegBase, MovieWriter): ...
88+
89+
class FFMpegFileWriter(FFMpegBase, FileMovieWriter):
90+
supported_formats: list[str]
91+
92+
class ImageMagickBase:
93+
@classmethod
94+
def bin_path(cls) -> str: ...
95+
@classmethod
96+
def isAvailable(cls) -> bool: ...
97+
98+
class ImageMagickWriter(ImageMagickBase, MovieWriter):
99+
input_names: str
100+
101+
class ImageMagickFileWriter(ImageMagickBase, FileMovieWriter):
102+
supported_formats: list[str]
103+
@property
104+
def input_names(self) -> str: ...
105+
106+
class HTMLWriter(FileMovieWriter):
107+
supported_formats: list[str]
108+
@classmethod
109+
def isAvailable(cls) -> bool: ...
110+
embed_frames: bool
111+
default_mode: str
112+
def __init__(self, fps: int = ..., codec: str | None = ..., bitrate: int | None = ..., extra_args: list[str] | None = ..., metadata: dict[str, str] | None = ..., embed_frames: bool = ..., default_mode: str = ..., embed_limit: float | None = ...) -> None: ...
113+
def setup(self, fig: Figure, outfile: str | Path, dpi: float | None = ..., frame_dir: str | Path | None = ...) -> None: ...
114+
def grab_frame(self, **savefig_kwargs): ...
115+
def finish(self) -> None: ...
116+
117+
class Animation:
118+
frame_seq: Iterable[Artist]
119+
event_source: Any
120+
def __init__(self, fig: Figure, event_source: Any | None = ..., blit: bool = ...) -> None: ...
121+
def __del__(self) -> None: ...
122+
def save(self, filename: str | Path, writer: MovieWriter | str | None = ..., fps: int | None = ..., dpi: float | None = ..., codec: str | None = ..., bitrate: int | None = ..., extra_args: list[str] | None = ..., metadata: dict[str, str] | None = ..., extra_anim: list[Animation] | None = ..., savefig_kwargs: dict[str, Any] | None = ..., *, progress_callback: Callable[[int, int], Any] | None = ...) -> None: ...
123+
def new_frame_seq(self) -> Iterable[Artist]: ...
124+
def new_saved_frame_seq(self) -> Iterable[Artist]: ...
125+
def to_html5_video(self, embed_limit: float | None = ...) -> str: ...
126+
def to_jshtml(self, fps: int | None = ..., embed_frames: bool = ..., default_mode: str | None = ...) -> str: ...
127+
def pause(self) -> None: ...
128+
def resume(self) -> None: ...
129+
130+
class TimedAnimation(Animation):
131+
repeat: bool
132+
def __init__(self, fig: Figure, interval: int = ..., repeat_delay: int = ..., repeat: bool = ..., event_source: TimerBase | None = ..., *args, **kwargs) -> None: ...
133+
134+
class ArtistAnimation(TimedAnimation):
135+
def __init__(self, fig: Figure, artists: list[Artist], *args, **kwargs) -> None: ...
136+
137+
class FuncAnimation(TimedAnimation):
138+
save_count: int
139+
def __init__(self, fig: Figure, func: Callable[..., Iterable[Artist]], frames: Iterable[Artist] | int | Generator[Artist, None, None] | None = ..., init_func: Callable[[], Iterable[Artist]] | None = ..., fargs: tuple[Any, ...] | None = ..., save_count: int | None = ..., *, cache_frame_data: bool = ..., **kwargs) -> None: ...

lib/matplotlib/artist.pyi

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
from . import cbook as cbook
2+
from .axes import Axes
3+
from .axes._base import _AxesBase
4+
from .backend_bases import RendererBase, MouseEvent
5+
from .cm import ScalarMappable
6+
from .colors import BoundaryNorm
7+
from .figure import Figure, FigureBase
8+
from .path import Path
9+
from .patches import Patch
10+
from .patheffects import AbstractPathEffect
11+
from .transforms import Bbox, IdentityTransform, Transform, TransformedBbox, TransformedPatchPath, TransformedPath
12+
13+
import numpy as np
14+
15+
from typing import Any, NamedTuple, Callable, TextIO, Type, TypeVar, overload
16+
from numpy.typing import ArrayLike
17+
18+
def allow_rasterization(draw): ...
19+
20+
class _XYPair(NamedTuple):
21+
x: ArrayLike
22+
y: ArrayLike
23+
24+
class _Unset: ...
25+
26+
class Artist:
27+
zorder: float
28+
def __init_subclass__(cls): ...
29+
stale_callback: Callable[[Artist, bool], None] | None
30+
figure: FigureBase | None
31+
clipbox: Bbox | None
32+
def __init__(self) -> None: ...
33+
def remove(self) -> None: ...
34+
def have_units(self) -> bool: ...
35+
# TODO units
36+
def convert_xunits(self, x): ...
37+
def convert_yunits(self, y): ...
38+
@property
39+
def axes(self) -> _AxesBase | None: ...
40+
@axes.setter
41+
def axes(self, new_axes: _AxesBase | None) -> None: ...
42+
@property
43+
def stale(self) -> bool: ...
44+
@stale.setter
45+
def stale(self, val: bool) -> None: ...
46+
def get_window_extent(self, renderer: RendererBase | None = ...) -> Bbox: ...
47+
def get_tightbbox(self, renderer: RendererBase | None = ...) -> Bbox | None: ...
48+
def add_callback(self, func: Callable[[Artist], Any]) -> int: ...
49+
def remove_callback(self, oid: int) -> None: ...
50+
def pchanged(self) -> None: ...
51+
def is_transform_set(self) -> bool: ...
52+
def set_transform(self, t: Transform) -> None: ...
53+
def get_transform(self) -> Transform: ...
54+
def get_children(self) -> list[Artist]: ...
55+
# TODO can these dicts be type narrowed? e.g. str keys
56+
def contains(self, mouseevent: MouseEvent) -> tuple[bool, dict[Any, Any]]: ...
57+
def pickable(self) -> bool: ...
58+
def pick(self, mouseevent: MouseEvent) -> None: ...
59+
def set_picker(self, picker: None | bool | float | Callable[[Artist, MouseEvent], tuple[bool, dict[Any, Any]]]) -> None: ...
60+
def get_picker(self) -> None | bool | float | Callable[[Artist, MouseEvent], tuple[bool, dict[Any, Any]]]: ...
61+
def get_url(self) -> str | None: ...
62+
def set_url(self, url: str | None) -> None: ...
63+
def get_gid(self) -> str | None: ...
64+
def set_gid(self, gid: str | None) -> None: ...
65+
def get_snap(self) -> bool | None: ...
66+
def set_snap(self, snap: bool | None) -> None: ...
67+
def get_sketch_params(self) -> tuple[float, float, float] | None: ...
68+
def set_sketch_params(self, scale: float | None = ..., length: float | None = ..., randomness: float | None = ...) -> None: ...
69+
def set_path_effects(self, path_effects: AbstractPathEffect) -> None: ...
70+
def get_path_effects(self) -> AbstractPathEffect: ...
71+
def get_figure(self) -> Figure | None: ...
72+
def set_figure(self, fig: Figure) -> None: ...
73+
def set_clip_box(self, clipbox: Bbox) -> None: ...
74+
def set_clip_path(self, path: Patch | Path | TransformedPath | TransformedPatchPath | None, transform: Transform | None = ...) -> None: ...
75+
def get_alpha(self) -> float | None: ...
76+
def get_visible(self) -> bool: ...
77+
def get_animated(self) -> bool: ...
78+
def get_in_layout(self) -> bool: ...
79+
def get_clip_on(self) -> bool: ...
80+
def get_clip_box(self) -> Bbox | None: ...
81+
def get_clip_path(self) -> Patch | Path | TransformedPath | TransformedPatchPath | None: ...
82+
def get_transformed_clip_path_and_affine(self) -> tuple[None, None] | tuple[Path, Transform]: ...
83+
def set_clip_on(self, b: bool) -> None: ...
84+
def get_rasterized(self) -> bool: ...
85+
def set_rasterized(self, rasterized: bool) -> None: ...
86+
def get_agg_filter(self): ...
87+
def set_agg_filter(self, filter_func: Callable[[ArrayLike, float], tuple[np.ndarray, float, float]]) -> None: ...
88+
def draw(self, renderer: RendererBase) -> None: ...
89+
def set_alpha(self, alpha: float | None) -> None: ...
90+
def set_visible(self, b: bool) -> None: ...
91+
def set_animated(self, b: bool) -> None: ...
92+
def set_in_layout(self, in_layout: bool) -> None: ...
93+
def get_label(self) -> object: ...
94+
def set_label(self, s: object) -> None: ...
95+
def get_zorder(self) -> float: ...
96+
def set_zorder(self, level: float) -> None: ...
97+
@property
98+
def sticky_edges(self) -> ArrayLike: ...
99+
def update_from(self, other: Artist) -> None: ...
100+
def properties(self) -> dict[str, Any]: ...
101+
def update(self, props: dict[str, Any]) -> Any: ...
102+
def _internal_update(self, kwargs): ...
103+
def set(self, **kwargs: Any): ...
104+
def findobj(self, match: None | Callable[[Artist], bool] | Type[Artist] = ..., include_self: bool = ...) -> list[Artist]: ...
105+
def get_cursor_data(self, event: MouseEvent) -> Any: ...
106+
def format_cursor_data(self, data: Any) -> str: ...
107+
def get_mouseover(self) -> bool: ...
108+
def set_mouseover(self, mouseover: bool) -> None: ...
109+
110+
class ArtistInspector:
111+
oorig: Artist | Type[Artist]
112+
o: Type[Artist]
113+
aliasd: dict[str, set[str]]
114+
def __init__(self, o) -> None: ...
115+
def get_aliases(self) -> dict[str, set[str]]: ...
116+
def get_valid_values(self, attr: str) -> str | None: ...
117+
def get_setters(self) -> list[str]: ...
118+
@staticmethod
119+
def number_of_parameters(func: Callable) -> int: ...
120+
@staticmethod
121+
def is_alias(method: Callable) -> bool: ...
122+
def aliased_name(self, s: str) -> str: ...
123+
def aliased_name_rest(self, s: str, target: str) -> str: ...
124+
@overload
125+
def pprint_setters(self, prop: None = ..., leadingspace: int = ...) -> list[str]: ...
126+
@overload
127+
def pprint_setters(self, prop: str, leadingspace: int = ...) -> str: ...
128+
@overload
129+
def pprint_setters_rest(self, prop: None = ..., leadingspace: int = ...) -> list[str]: ...
130+
@overload
131+
def pprint_setters_rest(self, prop: str, leadingspace: int = ...) -> str: ...
132+
def properties(self) -> dict[str, Any]: ...
133+
def pprint_getters(self) -> list[str]: ...
134+
135+
def getp(obj: Artist, property: str | None = ...) -> Any: ...
136+
get = getp
137+
138+
def setp(obj: Artist, *args, file: TextIO | None = ..., **kwargs): ...
139+
def kwdoc(artist: Artist) -> str: ...

lib/matplotlib/axes/__init__.pyi

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from ._axes import *
2+
3+
from ._axes import Axes as Subplot
4+
5+
class _SubplotBaseMeta(type):
6+
def __instancecheck__(self, obj) -> bool: ...
7+
8+
class SubplotBase(metaclass=_SubplotBaseMeta): ...
9+
10+
def subplot_class_factory(cls): ...

0 commit comments

Comments
 (0)