Skip to content

Commit

Permalink
pythongh-103056: [Enum] use staticmethod decorator for _gnv_ (pythonG…
Browse files Browse the repository at this point in the history
…H-103231)

_gnv_ --> _generate_next_value_
  • Loading branch information
ethanfurman authored Apr 4, 2023
1 parent c71756f commit 810d365
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions Doc/howto/enum.rst
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ The values are chosen by :func:`_generate_next_value_`, which can be
overridden::

>>> class AutoName(Enum):
... @staticmethod
... def _generate_next_value_(name, start, count, last_values):
... return name
...
Expand Down
3 changes: 3 additions & 0 deletions Lib/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,7 @@ def __new__(cls, value):
def __init__(self, *args, **kwds):
pass

@staticmethod
def _generate_next_value_(name, start, count, last_values):
"""
Generate the next value when not given.
Expand Down Expand Up @@ -1288,6 +1289,7 @@ def __new__(cls, *values):
member._value_ = value
return member

@staticmethod
def _generate_next_value_(name, start, count, last_values):
"""
Return the lower-cased version of the member name.
Expand Down Expand Up @@ -1337,6 +1339,7 @@ def __reduce_ex__(self, proto):

_numeric_repr_ = repr

@staticmethod
def _generate_next_value_(name, start, count, last_values):
"""
Generate the next value when not given.
Expand Down

0 comments on commit 810d365

Please sign in to comment.