Skip to content

Commit

Permalink
Revert "Remove matplotlib stubs and tests" (microsoft#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
debonte authored Sep 27, 2023
1 parent ef1bbd0 commit e328827
Show file tree
Hide file tree
Showing 123 changed files with 12,279 additions and 2 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ Stubs for the following libraries now exist in typeshed or the libraries themsel
- filelock
- freezegun
- jmespath
- matplotlib
- markdown
- netaddr
- openpyxl
Expand All @@ -58,6 +57,10 @@ Stubs for the following libraries now exist in typeshed or the libraries themsel
- sympy
- tenacity

The following libraries are `py.typed`. We still have stubs for them here, but we are no longer actively maintaining them. We continue to bundle them with Pylance so users on older, non-`py.typed` versions will still get type info. If you find problems in our stubs for these libraries, rather than filing an issue here, you should upgrade to the version shown below to get the official stubs:

- matplotlib (3.8.0)

# Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.
56 changes: 56 additions & 0 deletions stubs/matplotlib/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import numpy as np
from typing import Generator, Literal
from ._typing import *
import contextlib
from packaging.version import parse as parse_version
from . import _docstring, _version, cbook, rcsetup
from . import colors as colors

class __getattr__:

URL_REGEX = ...

def set_loglevel(
level: Literal["notset", "debug", "info", "warning", "error", "critical"]
)-> None: ...

class ExecutableNotFoundError(FileNotFoundError):
...

def checkdep_usetex(s)-> bool: ...
def get_configdir() -> str: ...
def get_cachedir() -> str: ...
def get_data_path() -> str: ...
def matplotlib_fname() -> str: ...

class RcParams(dict):

validate = ...
def __init__(self, *args, **kwargs) -> None: ...
def find_all(self, pattern)-> RcParams: ...
def copy(self)-> RcParams: ...

def rc_params(fail_on_error: bool = ...) -> RcParams: ...
def is_url(filename: str) -> bool: ...
def rc_params_from_file(
fname: str | PathLike, fail_on_error: bool = ..., use_default_template: bool = ...
) -> RcParams: ...

rcParamsDefault: RcParams = ...
rcParams: RcParams = ...
rcParamsOrig: RcParams = ...

def rc(group, **kwargs)-> None: ...
def rcdefaults()-> None: ...
def rc_file_defaults()-> None: ...
def rc_file(fname: str | PathLike, *, use_default_template: bool = ...)-> None: ...
@contextlib.contextmanager
def rc_context(rc: dict = ..., fname: str | PathLike = ...)-> Generator: ...
def use(backend: str, *, force: bool = True)-> None: ...
def get_backend() -> str: ...
def interactive(b) -> bool: ...
def is_interactive() -> bool: ...

default_test_modules: list[str] = ...

def test(verbosity=..., coverage=..., **kwargs): int: ...
32 changes: 32 additions & 0 deletions stubs/matplotlib/_afm.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import numpy as np
from ._typing import *

CharMetrics = ...
CompositePart = ...

class AFM:
def __init__(self, fh) -> None: ...
def get_bbox_char(self, c: str, isord: bool = False): ...
def string_width_height(self, s: str) -> tuple[float, float]: ...
def get_str_bbox_and_descent(self, s: str) -> tuple[float, ...]: ...
def get_str_bbox(self, s: str)-> tuple[float, ...]: ...
def get_name_char(self, c: str, isord: bool = False)-> str: ...
def get_width_char(self, c: str, isord: bool =False)-> float: ...
def get_width_from_char_name(self, name: str)-> float: ...
def get_height_char(self, c: str, isord: bool = False)-> float: ...
def get_kern_dist(self, c1: str, c2: str)-> float: ...
def get_kern_dist_from_name(self, name1: str, name2: str)-> float: ...
def get_fontname(self) -> str: ...
@property
def postscript_name(self)-> str: ...
def get_fullname(self) -> str: ...
def get_familyname(self) -> str: ...
@property
def family_name(self) -> str: ...
def get_weight(self) -> str: ...
def get_angle(self) -> float: ...
def get_capheight(self) -> float: ...
def get_xheight(self) -> float: ...
def get_underline_thickness(self) -> float: ...
def get_horizontal_stem_width(self) -> float | None: ...
def get_vertical_stem_width(self) -> float | None: ...
Empty file added stubs/matplotlib/_api.pyi
Empty file.
31 changes: 31 additions & 0 deletions stubs/matplotlib/_api/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from typing import Any, Callable, Generator, Iterable, Type

import functools
from .deprecation import (
MatplotlibDeprecationWarning,
)

class classproperty:
def __init__(
self, fget: Callable, fset: None = ..., fdel: None = ..., doc: None = ...
) -> None: ...
def __get__(self, instance, owner): ...
@property
def fget(self): ...

def check_isinstance(**kwargs) -> None: ...
def check_in_list(
_values: Iterable, *, _print_supported_values: bool = True, **kwargs
) -> None: ...
def check_shape(**kwargs) -> None: ...
def check_getitem(_mapping: dict, **kwargs): ...
def caching_module_getattr(cls) -> functools._lru_cache_wrapper: ...
def define_aliases(
alias_d: dict[str, list[str]], cls: None = ...
) -> functools.partial: ...
def select_matching_signature(funcs: list[Callable], *args, **kwargs): ...
def recursive_subclasses(cls) -> Generator: ...
def warn_external(
message: MatplotlibDeprecationWarning | PendingDeprecationWarning | str,
category: None | Type[MatplotlibDeprecationWarning] = ...,
) -> None: ...
51 changes: 51 additions & 0 deletions stubs/matplotlib/_api/deprecation.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from functools import partial
import contextlib
from typing import Callable, Iterator

class MatplotlibDeprecationWarning(DeprecationWarning): ...

def warn_deprecated(
since: str,
*,
message: str = ...,
name: str = ...,
alternative: str = ...,
pending: bool = ...,
obj_type: str = ...,
addendum: str = ...,
removal: str = ...
) -> None: ...
def deprecated(
since: str,
*,
message: str = ...,
name: str = ...,
alternative: str = ...,
pending: bool = ...,
obj_type: str = ...,
addendum: str = ...,
removal: str = ...
) -> Callable: ...

class deprecate_privatize_attribute:
def __init__(self, *args, **kwargs) -> None: ...
def __set_name__(self, owner, name) -> None: ...

DECORATORS: dict = ...

def rename_parameter(
since: str, old: str, new: str, func: None | Callable = ...
) -> partial | Callable: ...

class _deprecated_parameter_class:
def __repr__(self): ...

def delete_parameter(
since: str, name: str, func: None | Callable = ..., **kwargs
) -> partial | Callable: ...
def make_keyword_only(
since: str, name: str, func: None | Callable = ...
) -> partial | Callable: ...
def deprecate_method_override(method, obj, *, allow_empty: bool = ..., **kwargs): ...
@contextlib.contextmanager
def suppress_matplotlib_deprecation_warning() -> Iterator[None]: ...
Empty file.
10 changes: 10 additions & 0 deletions stubs/matplotlib/_cm.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from functools import partial
from typing import Any

def cubehelix(
gamma: float = 1, s: float = 0.5, r: float = -1.5, h: float = 1
) -> dict[str, partial]: ...

gfunc: dict[int, Any] = ...

datad: dict[str, tuple[float, ...]] = ...
4 changes: 4 additions & 0 deletions stubs/matplotlib/_color_data.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
BASE_COLORS: dict[str, tuple[float, float, float]] = ...
TABLEAU_COLORS: dict[str, str] = ...
XKCD_COLORS: dict[str, str] = ...
CSS4_COLORS: dict[str, str] = ...
31 changes: 31 additions & 0 deletions stubs/matplotlib/_constrained_layout.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from matplotlib.backend_bases import RendererBase
from .figure import Figure
from .axes import Axes
from .transforms import Bbox

def do_constrained_layout(
fig: Figure,
h_pad: float,
w_pad: float,
hspace: float|None = None,
wspace: float|None = None,
rect: tuple = ...
)-> dict: ...
def make_layoutgrids(fig, layoutgrids:dict, rect=...)-> dict: ...
def make_layoutgrids_gs(layoutgrids: dict, gs)-> dict: ...
def check_no_collapsed_axes(layoutgrids, fig: Figure)-> bool: ...
def compress_fixed_aspect(layoutgrids, fig: Figure): ...
def get_margin_from_padding(obj, *, w_pad: float=0, h_pad: float=0, hspace: float=0, wspace: float=0)-> dict: ...
def make_layout_margins(
layoutgrids: dict, fig: Figure, renderer: RendererBase, *, w_pad: float=0, h_pad: float=0, hspace: float=0, wspace: float=0
)-> dict: ...
def make_margin_suptitles(layoutgrids: dict, fig: Figure, renderer: RendererBase, *, w_pad: float=0, h_pad: float=0)-> None: ...
def match_submerged_margins(layoutgrids: dict, fig: Figure)-> None: ...
def get_cb_parent_spans(cbax)-> tuple[range, range]: ...
def get_pos_and_bbox(ax: Axes, renderer: RendererBase) -> tuple[Bbox, Bbox]: ...
def reposition_axes(
layoutgrids: dict, fig: Figure, renderer: RendererBase, *, w_pad: float=0, h_pad: float=0, hspace: float=0, wspace: float=0
)-> None: ...
def reposition_colorbar(layoutgrids: dict, cbax: Axes, renderer: RendererBase, *, offset: float|None=None)-> dict: ...
def reset_margins(layoutgrids: dict, fig: Figure)-> None: ...
def colorbar_get_pad(layoutgrids: dict, cax: Axes)-> float: ...
18 changes: 18 additions & 0 deletions stubs/matplotlib/_docstring.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from typing import Callable

class Substitution:
def __init__(self, *args, **kwargs) -> None: ...
def __call__(self, func: Callable) -> Callable: ...
def update(self, *args, **kwargs) -> None: ...

class _ArtistKwdocLoader(dict):
def __missing__(self, key: str) -> str: ...

class _ArtistPropertiesSubstitution(Substitution):
def __init__(self) -> None: ...
def __call__(self, obj: Callable) -> Callable: ...

def copy(source: Callable) -> Callable: ...

dedent_interpd: _ArtistPropertiesSubstitution = ...
interpd: _ArtistPropertiesSubstitution = ...
19 changes: 19 additions & 0 deletions stubs/matplotlib/_enums.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from enum import Enum

class _AutoStringNameEnum(Enum):
def __hash__(self) -> int: ...

class JoinStyle(str, _AutoStringNameEnum):

miter: JoinStyle
round: JoinStyle
bevel: JoinStyle
@staticmethod
def demo() -> None: ...

class CapStyle(str, _AutoStringNameEnum):
butt: CapStyle
projecting: CapStyle
round: CapStyle
@staticmethod
def demo() -> None: ...
16 changes: 16 additions & 0 deletions stubs/matplotlib/_fontconfig_pattern.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from .font_manager import FontProperties

family_punc = ...
family_unescape = ...
family_escape = ...
value_punc = ...
value_unescape = ...
value_escape = ...

class FontconfigPatternParser:
def __init__(self) -> None: ...
def parse(self, pattern: str) -> dict[str, list[str]]: ...

parse_fontconfig_pattern = ...

def generate_fontconfig_pattern(d: FontProperties) -> str: ...
60 changes: 60 additions & 0 deletions stubs/matplotlib/_layoutgrid.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from typing import Literal
from .gridspec import SubplotSpec
from .transforms import Bbox
from .figure import Figure

class LayoutGrid:
def __init__(
self,
parent: LayoutGrid | tuple[int, int, int, int]|None = None,
parent_pos: tuple[range, range] | tuple[int, int] = (0, 0),
parent_inner: bool = False,
name: str = '',
ncols: int = 1,
nrows: int = 1,
h_pad: float|None = None,
w_pad: float|None = None,
width_ratios: None | list[float] = None,
height_ratios: None | list[float] = None,
) -> None: ...
def __repr__(self) -> str: ...
def reset_margins(self) -> None: ...
def add_constraints(self) -> None: ...
def hard_constraints(self) -> None: ...
def add_child(
self,
child: LayoutGrid,
i: int | range = 0,
j: int | range = 0,
) -> None: ...
def parent_constraints(self) -> None: ...
def grid_constraints(self) -> None: ...
def edit_margin(
self, todo: Literal["left", "right", "bottom", "top"], size: float, cell: int
) -> None: ...
def edit_margin_min(
self,
todo: Literal["left", "right", "bottom", "top"],
size: float,
cell: int = 0,
) -> None: ...
def edit_margins(
self, todo: Literal["left", "right", "bottom", "top"], size: float
) -> None: ...
def edit_all_margins_min(
self, todo: Literal["left", "right", "bottom", "top"], size: float
): ...
def edit_outer_margin_mins(self, margin: dict, ss: SubplotSpec)-> None: ...
def get_margins(self, todo, col) -> Bbox: ...
def get_outer_bbox(self, rows=0, cols=0) -> Bbox: ...
def get_inner_bbox(self, rows=0, cols=0) -> Bbox: ...
def get_bbox_for_cb(self, rows=0, cols=0) -> Bbox: ...
def get_left_margin_bbox(self, rows=0, cols=0) -> Bbox: ...
def get_bottom_margin_bbox(self, rows=0, cols=0) -> Bbox: ...
def get_right_margin_bbox(self, rows=0, cols=0) -> Bbox: ...
def get_top_margin_bbox(self, rows=0, cols=0) -> Bbox: ...
def update_variables(self) -> None: ...

def seq_id() -> str: ...
def print_children(lb) -> None: ...
def plot_children(fig: Figure, lg=None, level: int=0, printit: bool=False)->None: ...
Loading

0 comments on commit e328827

Please sign in to comment.