Skip to content

Navigation Menu

Sign in
Appearance settings

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 5837e94

Browse filesBrowse files
committed
MNT: remove a private helper class
- The definition of `__hash__` was doing nothing - having a copy of a 1 line function in two sub-classes is simpler than having doing inheritance - fixes an issues with mypy failing on an Enum class with no entries
1 parent 18d42a6 commit 5837e94
Copy full SHA for 5837e94

File tree

2 files changed

+12
-13
lines changed
Filter options

2 files changed

+12
-13
lines changed

‎lib/matplotlib/_enums.py

Copy file name to clipboardExpand all lines: lib/matplotlib/_enums.py
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,11 @@
1414
from matplotlib import _docstring
1515

1616

17-
class _AutoStringNameEnum(Enum):
17+
class __AutoStringNameEnum(Enum):
1818
"""Automate the ``name = 'name'`` part of making a (str, Enum)."""
1919

20-
def _generate_next_value_(name, start, count, last_values):
21-
return name
22-
23-
def __hash__(self):
24-
return str(self).__hash__()
2520

26-
27-
class JoinStyle(str, _AutoStringNameEnum):
21+
class JoinStyle(str, Enum):
2822
"""
2923
Define how the connection between two line segments is drawn.
3024
@@ -79,6 +73,9 @@ class JoinStyle(str, _AutoStringNameEnum):
7973
8074
"""
8175

76+
def _generate_next_value_(name, start, count, last_values):
77+
return name
78+
8279
miter = auto()
8380
round = auto()
8481
bevel = auto()
@@ -116,7 +113,7 @@ def plot_angle(ax, x, y, angle, style):
116113
+ "}"
117114

118115

119-
class CapStyle(str, _AutoStringNameEnum):
116+
class CapStyle(str, Enum):
120117
r"""
121118
Define how the two endpoints (caps) of an unclosed line are drawn.
122119
@@ -151,6 +148,9 @@ class CapStyle(str, _AutoStringNameEnum):
151148
CapStyle.demo()
152149
153150
"""
151+
def _generate_next_value_(name, start, count, last_values):
152+
return name
153+
154154
butt = auto()
155155
projecting = auto()
156156
round = auto()

‎lib/matplotlib/_enums.pyi

Copy file name to clipboardExpand all lines: lib/matplotlib/_enums.pyi
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
from typing import cast
22
from enum import Enum
33

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

7-
class JoinStyle(str, _AutoStringNameEnum):
5+
class JoinStyle(str, Enum):
86
miter = cast(str, ...)
97
round = cast(str, ...)
108
bevel = cast(str, ...)
119
@staticmethod
1210
def demo() -> None: ...
1311

14-
class CapStyle(str, _AutoStringNameEnum):
12+
13+
class CapStyle(str, Enum):
1514
butt = cast(str, ...)
1615
projecting = cast(str, ...)
1716
round = cast(str, ...)

0 commit comments

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