Skip to content

gh-103056: use staticmethod decorator for _gnv_ #103231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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