From 810d365b5eb2cf3043957ca2971f6e7a7cd87d0d Mon Sep 17 00:00:00 2001 From: Ethan Furman Date: Mon, 3 Apr 2023 17:47:40 -0700 Subject: [PATCH] gh-103056: [Enum] use staticmethod decorator for _gnv_ (GH-103231) _gnv_ --> _generate_next_value_ --- Doc/howto/enum.rst | 1 + Lib/enum.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/Doc/howto/enum.rst b/Doc/howto/enum.rst index fc8ea55069a..38951ed7348 100644 --- a/Doc/howto/enum.rst +++ b/Doc/howto/enum.rst @@ -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 ... diff --git a/Lib/enum.py b/Lib/enum.py index 9d836c716d8..ec698d5fa3c 100644 --- a/Lib/enum.py +++ b/Lib/enum.py @@ -1146,6 +1146,7 @@ class Enum(metaclass=EnumType): def __init__(self, *args, **kwds): pass + @staticmethod def _generate_next_value_(name, start, count, last_values): """ Generate the next value when not given. @@ -1288,6 +1289,7 @@ class StrEnum(str, ReprEnum): member._value_ = value return member + @staticmethod def _generate_next_value_(name, start, count, last_values): """ Return the lower-cased version of the member name. @@ -1337,6 +1339,7 @@ class Flag(Enum, boundary=CONFORM): _numeric_repr_ = repr + @staticmethod def _generate_next_value_(name, start, count, last_values): """ Generate the next value when not given.