Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 677d990

Browse filesBrowse files
authored
Merge pull request #29362 from tacaswell/fix/mypy_enum_semantics
TYP: semantics of enums in stub files changed
2 parents 109f857 + 91b26c3 commit 677d990
Copy full SHA for 677d990

12 files changed

+112
-102
lines changed

‎lib/matplotlib/_enums.py

Copy file name to clipboardExpand all lines: lib/matplotlib/_enums.py
+9-19Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,11 @@
1010
they define.
1111
"""
1212

13-
from enum import Enum, auto
13+
from enum import Enum
1414
from matplotlib import _docstring
1515

1616

17-
class _AutoStringNameEnum(Enum):
18-
"""Automate the ``name = 'name'`` part of making a (str, Enum)."""
19-
20-
def _generate_next_value_(name, start, count, last_values):
21-
return name
22-
23-
def __hash__(self):
24-
return str(self).__hash__()
25-
26-
27-
class JoinStyle(str, _AutoStringNameEnum):
17+
class JoinStyle(str, Enum):
2818
"""
2919
Define how the connection between two line segments is drawn.
3020
@@ -79,9 +69,9 @@ class JoinStyle(str, _AutoStringNameEnum):
7969
8070
"""
8171

82-
miter = auto()
83-
round = auto()
84-
bevel = auto()
72+
miter = "miter"
73+
round = "round"
74+
bevel = "bevel"
8575

8676
@staticmethod
8777
def demo():
@@ -116,7 +106,7 @@ def plot_angle(ax, x, y, angle, style):
116106
+ "}"
117107

118108

119-
class CapStyle(str, _AutoStringNameEnum):
109+
class CapStyle(str, Enum):
120110
r"""
121111
Define how the two endpoints (caps) of an unclosed line are drawn.
122112
@@ -151,9 +141,9 @@ class CapStyle(str, _AutoStringNameEnum):
151141
CapStyle.demo()
152142
153143
"""
154-
butt = auto()
155-
projecting = auto()
156-
round = auto()
144+
butt = "butt"
145+
projecting = "projecting"
146+
round = "round"
157147

158148
@staticmethod
159149
def demo():

‎lib/matplotlib/_enums.pyi

Copy file name to clipboard
+11-10Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1+
from typing import cast
12
from enum import Enum
23

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

6-
class JoinStyle(str, _AutoStringNameEnum):
7-
miter: str
8-
round: str
9-
bevel: str
5+
class JoinStyle(str, Enum):
6+
miter = "miter"
7+
round = "round"
8+
bevel = "bevel"
109
@staticmethod
1110
def demo() -> None: ...
1211

13-
class CapStyle(str, _AutoStringNameEnum):
14-
butt: str
15-
projecting: str
16-
round: str
12+
13+
class CapStyle(str, Enum):
14+
butt = "butt"
15+
projecting = "projecting"
16+
round = "round"
17+
1718
@staticmethod
1819
def demo() -> None: ...

‎lib/matplotlib/backend_bases.pyi

Copy file name to clipboardExpand all lines: lib/matplotlib/backend_bases.pyi
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,11 @@ class LocationEvent(Event):
236236
) -> None: ...
237237

238238
class MouseButton(IntEnum):
239-
LEFT: int
240-
MIDDLE: int
241-
RIGHT: int
242-
BACK: int
243-
FORWARD: int
239+
LEFT = 1
240+
MIDDLE = 2
241+
RIGHT = 3
242+
BACK = 8
243+
FORWARD = 9
244244

245245
class MouseEvent(LocationEvent):
246246
button: MouseButton | Literal["up", "down"] | None
@@ -398,9 +398,9 @@ class FigureManagerBase:
398398
cursors = Cursors
399399

400400
class _Mode(str, Enum):
401-
NONE: str
402-
PAN: str
403-
ZOOM: str
401+
NONE = ""
402+
PAN = "pan/zoom"
403+
ZOOM = "zoom rect"
404404

405405
class NavigationToolbar2:
406406
toolitems: tuple[tuple[str, ...] | tuple[None, ...], ...]

‎lib/matplotlib/backend_tools.pyi

Copy file name to clipboardExpand all lines: lib/matplotlib/backend_tools.pyi
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ from matplotlib.backend_managers import ToolManager, ToolEvent
66
from matplotlib.figure import Figure
77
from matplotlib.scale import ScaleBase
88

9-
from typing import Any
9+
from typing import Any, cast
1010

1111
class Cursors(enum.IntEnum):
12-
POINTER: int
13-
HAND: int
14-
SELECT_REGION: int
15-
MOVE: int
16-
WAIT: int
17-
RESIZE_HORIZONTAL: int
18-
RESIZE_VERTICAL: int
12+
POINTER = cast(int, ...)
13+
HAND = cast(int, ...)
14+
SELECT_REGION = cast(int, ...)
15+
MOVE = cast(int, ...)
16+
WAIT = cast(int, ...)
17+
RESIZE_HORIZONTAL = cast(int, ...)
18+
RESIZE_VERTICAL = cast(int, ...)
1919

2020
cursors = Cursors
2121

‎lib/matplotlib/backends/registry.pyi

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/registry.pyi
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ from types import ModuleType
33

44

55
class BackendFilter(Enum):
6-
INTERACTIVE: int
7-
NON_INTERACTIVE: int
6+
INTERACTIVE = 0
7+
NON_INTERACTIVE = 1
88

99

1010
class BackendRegistry:

‎lib/matplotlib/dviread.pyi

Copy file name to clipboardExpand all lines: lib/matplotlib/dviread.pyi
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ from typing import NamedTuple
88
from typing_extensions import Self # < Py 3.11
99

1010
class _dvistate(Enum):
11-
pre: int
12-
outer: int
13-
inpage: int
14-
post_post: int
15-
finale: int
11+
pre = ...
12+
outer = ...
13+
inpage = ...
14+
post_post = ...
15+
finale = ...
1616

1717
class Page(NamedTuple):
1818
text: list[Text]

‎lib/matplotlib/ft2font.pyi

Copy file name to clipboardExpand all lines: lib/matplotlib/ft2font.pyi
+50-50Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from enum import Enum, Flag
22
import sys
3-
from typing import BinaryIO, Literal, TypedDict, final, overload
3+
from typing import BinaryIO, Literal, TypedDict, final, overload, cast
44
from typing_extensions import Buffer # < Py 3.12
55

66
import numpy as np
@@ -10,62 +10,62 @@ __freetype_build_type__: str
1010
__freetype_version__: str
1111

1212
class FaceFlags(Flag):
13-
SCALABLE: int
14-
FIXED_SIZES: int
15-
FIXED_WIDTH: int
16-
SFNT: int
17-
HORIZONTAL: int
18-
VERTICAL: int
19-
KERNING: int
20-
FAST_GLYPHS: int
21-
MULTIPLE_MASTERS: int
22-
GLYPH_NAMES: int
23-
EXTERNAL_STREAM: int
24-
HINTER: int
25-
CID_KEYED: int
26-
TRICKY: int
27-
COLOR: int
28-
# VARIATION: int # FT 2.9
29-
# SVG: int # FT 2.12
30-
# SBIX: int # FT 2.12
31-
# SBIX_OVERLAY: int # FT 2.12
13+
SCALABLE = cast(int, ...)
14+
FIXED_SIZES = cast(int, ...)
15+
FIXED_WIDTH = cast(int, ...)
16+
SFNT = cast(int, ...)
17+
HORIZONTAL = cast(int, ...)
18+
VERTICAL = cast(int, ...)
19+
KERNING = cast(int, ...)
20+
FAST_GLYPHS = cast(int, ...)
21+
MULTIPLE_MASTERS = cast(int, ...)
22+
GLYPH_NAMES = cast(int, ...)
23+
EXTERNAL_STREAM = cast(int, ...)
24+
HINTER = cast(int, ...)
25+
CID_KEYED = cast(int, ...)
26+
TRICKY = cast(int, ...)
27+
COLOR = cast(int, ...)
28+
# VARIATION = cast(int, ...) # FT 2.9
29+
# SVG = cast(int, ...) # FT 2.12
30+
# SBIX = cast(int, ...) # FT 2.12
31+
# SBIX_OVERLAY = cast(int, ...) # FT 2.12
3232

3333
class Kerning(Enum):
34-
DEFAULT: int
35-
UNFITTED: int
36-
UNSCALED: int
34+
DEFAULT = cast(int, ...)
35+
UNFITTED = cast(int, ...)
36+
UNSCALED = cast(int, ...)
3737

3838
class LoadFlags(Flag):
39-
DEFAULT: int
40-
NO_SCALE: int
41-
NO_HINTING: int
42-
RENDER: int
43-
NO_BITMAP: int
44-
VERTICAL_LAYOUT: int
45-
FORCE_AUTOHINT: int
46-
CROP_BITMAP: int
47-
PEDANTIC: int
48-
IGNORE_GLOBAL_ADVANCE_WIDTH: int
49-
NO_RECURSE: int
50-
IGNORE_TRANSFORM: int
51-
MONOCHROME: int
52-
LINEAR_DESIGN: int
53-
NO_AUTOHINT: int
54-
COLOR: int
55-
COMPUTE_METRICS: int # FT 2.6.1
56-
# BITMAP_METRICS_ONLY: int # FT 2.7.1
57-
# NO_SVG: int # FT 2.13.1
39+
DEFAULT = cast(int, ...)
40+
NO_SCALE = cast(int, ...)
41+
NO_HINTING = cast(int, ...)
42+
RENDER = cast(int, ...)
43+
NO_BITMAP = cast(int, ...)
44+
VERTICAL_LAYOUT = cast(int, ...)
45+
FORCE_AUTOHINT = cast(int, ...)
46+
CROP_BITMAP = cast(int, ...)
47+
PEDANTIC = cast(int, ...)
48+
IGNORE_GLOBAL_ADVANCE_WIDTH = cast(int, ...)
49+
NO_RECURSE = cast(int, ...)
50+
IGNORE_TRANSFORM = cast(int, ...)
51+
MONOCHROME = cast(int, ...)
52+
LINEAR_DESIGN = cast(int, ...)
53+
NO_AUTOHINT = cast(int, ...)
54+
COLOR = cast(int, ...)
55+
COMPUTE_METRICS = cast(int, ...) # FT 2.6.1
56+
# BITMAP_METRICS_ONLY = cast(int, ...) # FT 2.7.1
57+
# NO_SVG = cast(int, ...) # FT 2.13.1
5858
# The following should be unique, but the above can be OR'd together.
59-
TARGET_NORMAL: int
60-
TARGET_LIGHT: int
61-
TARGET_MONO: int
62-
TARGET_LCD: int
63-
TARGET_LCD_V: int
59+
TARGET_NORMAL = cast(int, ...)
60+
TARGET_LIGHT = cast(int, ...)
61+
TARGET_MONO = cast(int, ...)
62+
TARGET_LCD = cast(int, ...)
63+
TARGET_LCD_V = cast(int, ...)
6464

6565
class StyleFlags(Flag):
66-
NORMAL: int
67-
ITALIC: int
68-
BOLD: int
66+
NORMAL = cast(int, ...)
67+
ITALIC = cast(int, ...)
68+
BOLD = cast(int, ...)
6969

7070
class _SfntHeadDict(TypedDict):
7171
version: tuple[int, int]

‎lib/matplotlib/stackplot.pyi

Copy file name to clipboardExpand all lines: lib/matplotlib/stackplot.pyi
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ def stackplot(
1616
baseline: Literal["zero", "sym", "wiggle", "weighted_wiggle"] = ...,
1717
**kwargs
1818
) -> list[PolyCollection]: ...
19+
20+
__all__ = ['stackplot']

‎lib/matplotlib/streamplot.pyi

Copy file name to clipboardExpand all lines: lib/matplotlib/streamplot.pyi
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,5 @@ class StreamMask:
8282
class InvalidIndexError(Exception): ...
8383
class TerminateTrajectory(Exception): ...
8484
class OutOfBounds(IndexError): ...
85+
86+
__all__ = ['streamplot']

‎lib/matplotlib/style/core.pyi

Copy file name to clipboardExpand all lines: lib/matplotlib/style/core.pyi
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ library: dict[str, RcParams]
1717
available: list[str]
1818

1919
def reload_library() -> None: ...
20+
21+
__all__ = ['use', 'context', 'available', 'library', 'reload_library']

‎lib/matplotlib/ticker.pyi

Copy file name to clipboardExpand all lines: lib/matplotlib/ticker.pyi
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,3 +295,14 @@ class AutoLocator(MaxNLocator):
295295
class AutoMinorLocator(Locator):
296296
ndivs: int
297297
def __init__(self, n: int | None = ...) -> None: ...
298+
299+
__all__ = ('TickHelper', 'Formatter', 'FixedFormatter',
300+
'NullFormatter', 'FuncFormatter', 'FormatStrFormatter',
301+
'StrMethodFormatter', 'ScalarFormatter', 'LogFormatter',
302+
'LogFormatterExponent', 'LogFormatterMathtext',
303+
'LogFormatterSciNotation',
304+
'LogitFormatter', 'EngFormatter', 'PercentFormatter',
305+
'Locator', 'IndexLocator', 'FixedLocator', 'NullLocator',
306+
'LinearLocator', 'LogLocator', 'AutoLocator',
307+
'MultipleLocator', 'MaxNLocator', 'AutoMinorLocator',
308+
'SymmetricalLogLocator', 'AsinhLocator', 'LogitLocator')

‎lib/matplotlib/tri/_triinterpolate.pyi

Copy file name to clipboardExpand all lines: lib/matplotlib/tri/_triinterpolate.pyi
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ class CubicTriInterpolator(TriInterpolator):
2828
trifinder: TriFinder | None = ...,
2929
dz: tuple[ArrayLike, ArrayLike] | None = ...,
3030
) -> None: ...
31+
32+
__all__ = ('TriInterpolator', 'LinearTriInterpolator', 'CubicTriInterpolator')

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.