Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 88b0af4

Browse files
tacaswelltimhoffm
authored andcommitted
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 d6606c2 commit 88b0af4

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

lib/matplotlib/_enums.py

Lines 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

Lines 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)