Skip to content
Open
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
1 change: 0 additions & 1 deletion ci/mypy-stubtest-allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ matplotlib\.backends\..*
matplotlib\.tests(\..*)?
matplotlib\.pylab(\..*)?
matplotlib\._.*
matplotlib\.rcsetup\._listify_validator
matplotlib\.rcsetup\._validate_linestyle
matplotlib\.ft2font\.Glyph
matplotlib\.ft2font\.LayoutItem
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/artist.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ _T_Artist = TypeVar("_T_Artist", bound=Artist)
def allow_rasterization(draw): ...

class _XYPair(NamedTuple):
x: ArrayLike
y: ArrayLike
x: list[float]
y: list[float]

class Artist:
zorder: float
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/axes/_base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class _AxesBase(martist.Artist):

def __init__(
self,
fig: Figure,
fig: Figure | SubFigure,
*args: tuple[float, float, float, float] | Bbox | int,
facecolor: ColorType | None = ...,
frameon: bool = ...,
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/registry.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class BackendRegistry:
def backend_for_gui_framework(self, framework: str) -> str | None: ...
def is_valid_backend(self, backend: str) -> bool: ...
def list_all(self) -> list[str]: ...
def list_builtin(self, filter_: BackendFilter | None) -> list[str]: ...
def list_builtin(self, filter_: BackendFilter | None = ...) -> list[str]: ...
def list_gui_frameworks(self) -> list[str]: ...
def load_backend_module(self, backend: str) -> ModuleType: ...
def resolve_backend(self, backend: str | None) -> tuple[str, str | None]: ...
Expand Down
7 changes: 4 additions & 3 deletions lib/matplotlib/colorbar.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ from collections.abc import Sequence
from typing import Any, Literal, overload
from .typing import ColorType

class _ColorbarSpine(mspines.Spines):

class _ColorbarSpine(mspines.Spine):
def __init__(self, axes: Axes): ...
def get_window_extent(self, renderer: RendererBase | None = ...) -> Bbox:...
def get_window_extent(self, renderer: RendererBase | None = ...) -> Bbox: ...
def set_xy(self, xy: ArrayLike) -> None: ...
def draw(self, renderer: RendererBase | None) -> None:...
def draw(self, renderer: RendererBase | None) -> None: ...


class Colorbar:
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/font_manager.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class FontManager:
rebuild_if_missing: bool = ...,
) -> list[FontPath]: ...

def is_opentype_cff_font(filename: str) -> bool: ...
def is_opentype_cff_font(filename: str | os.PathLike) -> bool: ...
def get_font(
font_filepaths: Iterable[str | bytes | os.PathLike | FontPath] | str | bytes | os.PathLike | FontPath,
) -> ft2font.FT2Font: ...
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/image.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class _ImageBase(colorizer.ColorizingArtist):
self, renderer: RendererBase, magnification: float = ..., unsampled: bool = ...
) -> tuple[np.ndarray, float, float, Affine2D]: ...
def draw(self, renderer: RendererBase) -> None: ...
def write_png(self, fname: str | pathlib.Path | BinaryIO) -> None: ...
def write_png(self, fname: str | os.PathLike | BinaryIO) -> None: ...
def set_data(self, A: ArrayLike | None) -> None: ...
def set_array(self, A: ArrayLike | None) -> None: ...
def get_shape(self) -> tuple[int, int, int]: ...
Expand Down
8 changes: 7 additions & 1 deletion lib/matplotlib/rcsetup.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ from matplotlib.typing import ColorType, LineStyleType, MarkEveryType

_T = TypeVar("_T")

def _listify_validator(s: Callable[[Any], _T]) -> Callable[[Any], list[_T]]: ...
def _listify_validator(
scalar_validator: Callable[[Any], _T],
allow_stringlist: bool = ...,
*,
n: int | None = ...,
doc: str | None = ...,
) -> Callable[[Any], list[_T]]: ...

class ValidateInStrings:
key: str
Expand Down
5 changes: 3 additions & 2 deletions lib/matplotlib/testing/compare.pyi
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
from collections.abc import Callable
from os import PathLike
from typing import Literal, overload

from numpy.typing import NDArray

__all__ = ["calculate_rms", "comparable_formats", "compare_images"]

def make_test_filename(fname: str, purpose: str) -> str: ...
def make_test_filename(fname: str | PathLike, purpose: str) -> str: ...
def get_cache_dir() -> str: ...
def get_file_hash(path: str, block_size: int = ...) -> str: ...

converter: dict[str, Callable[[str, str], None]] = {}

def comparable_formats() -> list[str]: ...
def convert(filename: str, cache: bool) -> str: ...
def convert(filename: str | PathLike, cache: bool) -> str: ...
def crop_to_same(
actual_path: str, actual_image: NDArray, expected_path: str, expected_image: NDArray
) -> tuple[NDArray, NDArray]: ...
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def invalidate(self):
Invalidate this `TransformNode` and triggers an invalidation of its
ancestors. Should be called any time the transform changes.
"""
return self._invalidate_internal(
self._invalidate_internal(
level=self._INVALID_AFFINE_ONLY if self.is_affine else self._INVALID_FULL,
invalidating_node=self)

Expand Down
30 changes: 27 additions & 3 deletions lib/matplotlib/transforms.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ from typing import Literal
DEBUG: bool

class TransformNode:
INVALID_NON_AFFINE: int
INVALID_AFFINE: int
INVALID: int
# Implemented as a standard attr in base class, but functionally readonly and some subclasses implement as such
@property
def is_affine(self) -> bool: ...
Expand Down Expand Up @@ -130,12 +127,39 @@ class Bbox(BboxBase):
updatex: bool = ...,
updatey: bool = ...,
) -> None: ...
# Access to the parent class property is broken in mypy right now, so ignore that
# check for the following read/write properties.
# https://github.com/python/mypy/issues/5936
@BboxBase.x0.setter # type: ignore[attr-defined]
def x0(self, val: float) -> None: ...
@BboxBase.y0.setter # type: ignore[attr-defined]
def y0(self, val: float) -> None: ...
@BboxBase.x1.setter # type: ignore[attr-defined]
def x1(self, val: float) -> None: ...
@BboxBase.y1.setter # type: ignore[attr-defined]
def y1(self, val: float) -> None: ...
@BboxBase.p0.setter # type: ignore[attr-defined]
def p0(self, val: tuple[float, float]) -> None: ...
@BboxBase.p1.setter # type: ignore[attr-defined]
def p1(self, val: tuple[float, float]) -> None: ...
@BboxBase.intervalx.setter # type: ignore[attr-defined]
def intervalx(self, interval: tuple[float, float]) -> None: ...
@BboxBase.intervaly.setter # type: ignore[attr-defined]
def intervaly(self, interval: tuple[float, float]) -> None: ...
@BboxBase.bounds.setter # type: ignore[attr-defined]
def bounds(self, bounds: tuple[float, float, float, float]) -> None: ...
@property
def minpos(self) -> float: ...
@minpos.setter # type: ignore[attr-defined]
def minpos(self, val: float) -> None: ...
@property
def minposx(self) -> float: ...
@minposx.setter # type: ignore[attr-defined]
def minposx(self, val: float) -> None: ...
@property
def minposy(self) -> float: ...
@minposy.setter # type: ignore[attr-defined]
def minposy(self, val: float) -> None: ...
def get_points(self) -> np.ndarray: ...
def set_points(self, points: ArrayLike) -> None: ...
def set(self, other: Bbox) -> None: ...
Expand Down
Loading