]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-103056: [Enum] use staticmethod decorator for _gnv_ (GH-103231)
authorEthan Furman <ethan@stoneleaf.us>
Tue, 4 Apr 2023 00:47:40 +0000 (17:47 -0700)
committerGitHub <noreply@github.com>
Tue, 4 Apr 2023 00:47:40 +0000 (17:47 -0700)
_gnv_ --> _generate_next_value_

Doc/howto/enum.rst
Lib/enum.py

index fc8ea55069a9ece561ec1eaabdde13dd9da3c284..38951ed7348f56400af1b5bc6af299f0bf6dcfcd 100644 (file)
@@ -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
     ...
index 9d836c716d8423fb7c68cc9e1fe5257048c533fb..ec698d5fa3c30053a3581901e15c7692108d0e30 100644 (file)
@@ -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.