diff --git a/lib/matplotlib/_enums.py b/lib/matplotlib/_enums.py index 773011d36bf6..75a09b7b5d8c 100644 --- a/lib/matplotlib/_enums.py +++ b/lib/matplotlib/_enums.py @@ -10,21 +10,11 @@ they define. """ -from enum import Enum, auto +from enum import Enum from matplotlib import _docstring -class _AutoStringNameEnum(Enum): - """Automate the ``name = 'name'`` part of making a (str, Enum).""" - - def _generate_next_value_(name, start, count, last_values): - return name - - def __hash__(self): - return str(self).__hash__() - - -class JoinStyle(str, _AutoStringNameEnum): +class JoinStyle(str, Enum): """ Define how the connection between two line segments is drawn. @@ -79,9 +69,9 @@ class JoinStyle(str, _AutoStringNameEnum): """ - miter = auto() - round = auto() - bevel = auto() + miter = "miter" + round = "round" + bevel = "bevel" @staticmethod def demo(): @@ -116,7 +106,7 @@ def plot_angle(ax, x, y, angle, style): + "}" -class CapStyle(str, _AutoStringNameEnum): +class CapStyle(str, Enum): r""" Define how the two endpoints (caps) of an unclosed line are drawn. @@ -151,9 +141,9 @@ class CapStyle(str, _AutoStringNameEnum): CapStyle.demo() """ - butt = auto() - projecting = auto() - round = auto() + butt = "butt" + projecting = "projecting" + round = "round" @staticmethod def demo(): diff --git a/lib/matplotlib/_enums.pyi b/lib/matplotlib/_enums.pyi index 351088b36453..714e6cfe03fa 100644 --- a/lib/matplotlib/_enums.pyi +++ b/lib/matplotlib/_enums.pyi @@ -1,18 +1,19 @@ +from typing import cast from enum import Enum -class _AutoStringNameEnum(Enum): - def __hash__(self) -> int: ... -class JoinStyle(str, _AutoStringNameEnum): - miter: str - round: str - bevel: str +class JoinStyle(str, Enum): + miter = "miter" + round = "round" + bevel = "bevel" @staticmethod def demo() -> None: ... -class CapStyle(str, _AutoStringNameEnum): - butt: str - projecting: str - round: str + +class CapStyle(str, Enum): + butt = "butt" + projecting = "projecting" + round = "round" + @staticmethod def demo() -> None: ... diff --git a/lib/matplotlib/backend_bases.pyi b/lib/matplotlib/backend_bases.pyi index 8089bb49e597..23a19b79d3be 100644 --- a/lib/matplotlib/backend_bases.pyi +++ b/lib/matplotlib/backend_bases.pyi @@ -236,11 +236,11 @@ class LocationEvent(Event): ) -> None: ... class MouseButton(IntEnum): - LEFT: int - MIDDLE: int - RIGHT: int - BACK: int - FORWARD: int + LEFT = 1 + MIDDLE = 2 + RIGHT = 3 + BACK = 8 + FORWARD = 9 class MouseEvent(LocationEvent): button: MouseButton | Literal["up", "down"] | None @@ -398,9 +398,9 @@ class FigureManagerBase: cursors = Cursors class _Mode(str, Enum): - NONE: str - PAN: str - ZOOM: str + NONE = "" + PAN = "pan/zoom" + ZOOM = "zoom rect" class NavigationToolbar2: toolitems: tuple[tuple[str, ...] | tuple[None, ...], ...] diff --git a/lib/matplotlib/backend_tools.pyi b/lib/matplotlib/backend_tools.pyi index f86a207c7545..32fe8c2f5a79 100644 --- a/lib/matplotlib/backend_tools.pyi +++ b/lib/matplotlib/backend_tools.pyi @@ -6,16 +6,16 @@ from matplotlib.backend_managers import ToolManager, ToolEvent from matplotlib.figure import Figure from matplotlib.scale import ScaleBase -from typing import Any +from typing import Any, cast class Cursors(enum.IntEnum): - POINTER: int - HAND: int - SELECT_REGION: int - MOVE: int - WAIT: int - RESIZE_HORIZONTAL: int - RESIZE_VERTICAL: int + POINTER = cast(int, ...) + HAND = cast(int, ...) + SELECT_REGION = cast(int, ...) + MOVE = cast(int, ...) + WAIT = cast(int, ...) + RESIZE_HORIZONTAL = cast(int, ...) + RESIZE_VERTICAL = cast(int, ...) cursors = Cursors diff --git a/lib/matplotlib/backends/registry.pyi b/lib/matplotlib/backends/registry.pyi index e1ae5b3e7d3a..565f044bf212 100644 --- a/lib/matplotlib/backends/registry.pyi +++ b/lib/matplotlib/backends/registry.pyi @@ -3,8 +3,8 @@ from types import ModuleType class BackendFilter(Enum): - INTERACTIVE: int - NON_INTERACTIVE: int + INTERACTIVE = 0 + NON_INTERACTIVE = 1 class BackendRegistry: diff --git a/lib/matplotlib/dviread.pyi b/lib/matplotlib/dviread.pyi index 270818278f17..8073ee9fbff8 100644 --- a/lib/matplotlib/dviread.pyi +++ b/lib/matplotlib/dviread.pyi @@ -8,11 +8,11 @@ from typing import NamedTuple from typing_extensions import Self # < Py 3.11 class _dvistate(Enum): - pre: int - outer: int - inpage: int - post_post: int - finale: int + pre = ... + outer = ... + inpage = ... + post_post = ... + finale = ... class Page(NamedTuple): text: list[Text] diff --git a/lib/matplotlib/ft2font.pyi b/lib/matplotlib/ft2font.pyi index 1638bac692d3..811f82f95963 100644 --- a/lib/matplotlib/ft2font.pyi +++ b/lib/matplotlib/ft2font.pyi @@ -1,6 +1,6 @@ from enum import Enum, Flag import sys -from typing import BinaryIO, Literal, TypedDict, final, overload +from typing import BinaryIO, Literal, TypedDict, final, overload, cast from typing_extensions import Buffer # < Py 3.12 import numpy as np @@ -10,62 +10,62 @@ __freetype_build_type__: str __freetype_version__: str class FaceFlags(Flag): - SCALABLE: int - FIXED_SIZES: int - FIXED_WIDTH: int - SFNT: int - HORIZONTAL: int - VERTICAL: int - KERNING: int - FAST_GLYPHS: int - MULTIPLE_MASTERS: int - GLYPH_NAMES: int - EXTERNAL_STREAM: int - HINTER: int - CID_KEYED: int - TRICKY: int - COLOR: int - # VARIATION: int # FT 2.9 - # SVG: int # FT 2.12 - # SBIX: int # FT 2.12 - # SBIX_OVERLAY: int # FT 2.12 + SCALABLE = cast(int, ...) + FIXED_SIZES = cast(int, ...) + FIXED_WIDTH = cast(int, ...) + SFNT = cast(int, ...) + HORIZONTAL = cast(int, ...) + VERTICAL = cast(int, ...) + KERNING = cast(int, ...) + FAST_GLYPHS = cast(int, ...) + MULTIPLE_MASTERS = cast(int, ...) + GLYPH_NAMES = cast(int, ...) + EXTERNAL_STREAM = cast(int, ...) + HINTER = cast(int, ...) + CID_KEYED = cast(int, ...) + TRICKY = cast(int, ...) + COLOR = cast(int, ...) + # VARIATION = cast(int, ...) # FT 2.9 + # SVG = cast(int, ...) # FT 2.12 + # SBIX = cast(int, ...) # FT 2.12 + # SBIX_OVERLAY = cast(int, ...) # FT 2.12 class Kerning(Enum): - DEFAULT: int - UNFITTED: int - UNSCALED: int + DEFAULT = cast(int, ...) + UNFITTED = cast(int, ...) + UNSCALED = cast(int, ...) class LoadFlags(Flag): - DEFAULT: int - NO_SCALE: int - NO_HINTING: int - RENDER: int - NO_BITMAP: int - VERTICAL_LAYOUT: int - FORCE_AUTOHINT: int - CROP_BITMAP: int - PEDANTIC: int - IGNORE_GLOBAL_ADVANCE_WIDTH: int - NO_RECURSE: int - IGNORE_TRANSFORM: int - MONOCHROME: int - LINEAR_DESIGN: int - NO_AUTOHINT: int - COLOR: int - COMPUTE_METRICS: int # FT 2.6.1 - # BITMAP_METRICS_ONLY: int # FT 2.7.1 - # NO_SVG: int # FT 2.13.1 + DEFAULT = cast(int, ...) + NO_SCALE = cast(int, ...) + NO_HINTING = cast(int, ...) + RENDER = cast(int, ...) + NO_BITMAP = cast(int, ...) + VERTICAL_LAYOUT = cast(int, ...) + FORCE_AUTOHINT = cast(int, ...) + CROP_BITMAP = cast(int, ...) + PEDANTIC = cast(int, ...) + IGNORE_GLOBAL_ADVANCE_WIDTH = cast(int, ...) + NO_RECURSE = cast(int, ...) + IGNORE_TRANSFORM = cast(int, ...) + MONOCHROME = cast(int, ...) + LINEAR_DESIGN = cast(int, ...) + NO_AUTOHINT = cast(int, ...) + COLOR = cast(int, ...) + COMPUTE_METRICS = cast(int, ...) # FT 2.6.1 + # BITMAP_METRICS_ONLY = cast(int, ...) # FT 2.7.1 + # NO_SVG = cast(int, ...) # FT 2.13.1 # The following should be unique, but the above can be OR'd together. - TARGET_NORMAL: int - TARGET_LIGHT: int - TARGET_MONO: int - TARGET_LCD: int - TARGET_LCD_V: int + TARGET_NORMAL = cast(int, ...) + TARGET_LIGHT = cast(int, ...) + TARGET_MONO = cast(int, ...) + TARGET_LCD = cast(int, ...) + TARGET_LCD_V = cast(int, ...) class StyleFlags(Flag): - NORMAL: int - ITALIC: int - BOLD: int + NORMAL = cast(int, ...) + ITALIC = cast(int, ...) + BOLD = cast(int, ...) class _SfntHeadDict(TypedDict): version: tuple[int, int] diff --git a/lib/matplotlib/stackplot.pyi b/lib/matplotlib/stackplot.pyi index 2981d449b566..9509f858a4bf 100644 --- a/lib/matplotlib/stackplot.pyi +++ b/lib/matplotlib/stackplot.pyi @@ -16,3 +16,5 @@ def stackplot( baseline: Literal["zero", "sym", "wiggle", "weighted_wiggle"] = ..., **kwargs ) -> list[PolyCollection]: ... + +__all__ = ['stackplot'] diff --git a/lib/matplotlib/streamplot.pyi b/lib/matplotlib/streamplot.pyi index 9da83096e5a8..be7458020449 100644 --- a/lib/matplotlib/streamplot.pyi +++ b/lib/matplotlib/streamplot.pyi @@ -80,3 +80,5 @@ class StreamMask: class InvalidIndexError(Exception): ... class TerminateTrajectory(Exception): ... class OutOfBounds(IndexError): ... + +__all__ = ['streamplot'] diff --git a/lib/matplotlib/style/core.pyi b/lib/matplotlib/style/core.pyi index 73400492143c..5734b017f7c4 100644 --- a/lib/matplotlib/style/core.pyi +++ b/lib/matplotlib/style/core.pyi @@ -17,3 +17,5 @@ library: dict[str, RcParams] available: list[str] def reload_library() -> None: ... + +__all__ = ['use', 'context', 'available', 'library', 'reload_library'] diff --git a/lib/matplotlib/ticker.pyi b/lib/matplotlib/ticker.pyi index f990bf53ca42..bed288658909 100644 --- a/lib/matplotlib/ticker.pyi +++ b/lib/matplotlib/ticker.pyi @@ -295,3 +295,14 @@ class AutoLocator(MaxNLocator): class AutoMinorLocator(Locator): ndivs: int def __init__(self, n: int | None = ...) -> None: ... + +__all__ = ('TickHelper', 'Formatter', 'FixedFormatter', + 'NullFormatter', 'FuncFormatter', 'FormatStrFormatter', + 'StrMethodFormatter', 'ScalarFormatter', 'LogFormatter', + 'LogFormatterExponent', 'LogFormatterMathtext', + 'LogFormatterSciNotation', + 'LogitFormatter', 'EngFormatter', 'PercentFormatter', + 'Locator', 'IndexLocator', 'FixedLocator', 'NullLocator', + 'LinearLocator', 'LogLocator', 'AutoLocator', + 'MultipleLocator', 'MaxNLocator', 'AutoMinorLocator', + 'SymmetricalLogLocator', 'AsinhLocator', 'LogitLocator') diff --git a/lib/matplotlib/tri/_triinterpolate.pyi b/lib/matplotlib/tri/_triinterpolate.pyi index 8a56b22acdb2..33b2fd8be4cd 100644 --- a/lib/matplotlib/tri/_triinterpolate.pyi +++ b/lib/matplotlib/tri/_triinterpolate.pyi @@ -28,3 +28,5 @@ class CubicTriInterpolator(TriInterpolator): trifinder: TriFinder | None = ..., dz: tuple[ArrayLike, ArrayLike] | None = ..., ) -> None: ... + +__all__ = ('TriInterpolator', 'LinearTriInterpolator', 'CubicTriInterpolator')