summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Pope <nick@nickpope.me.uk>2023-08-23 12:09:28 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-09-13 08:22:45 +0200
commit170b0a47b09d735132bcfdcc9b303397eb03b34b (patch)
treef9b567eb564c40d4fbc89455538a93f775d77b21
parente15174983adf0ee5caa1b678c94bb1c6fbd40402 (diff)
Refs #34233 -- Used @staticmethod with TextChoices._generate_next_value_().
Now that Python 3.10 is the minimum supported version, we can decorate _generate_next_value_() with @staticmethod. It wasn't possible before as Python < 3.10 does not support calling static methods direct from the class body. https://docs.python.org/3/library/enum.html#enum.Enum._generate_next_value_
-rw-r--r--django/db/models/enums.py1
1 files changed, 1 insertions, 0 deletions
diff --git a/django/db/models/enums.py b/django/db/models/enums.py
index 20e9e77925..24bec6b87b 100644
--- a/django/db/models/enums.py
+++ b/django/db/models/enums.py
@@ -98,6 +98,7 @@ class IntegerChoices(int, Choices):
class TextChoices(str, Choices):
"""Class for creating enumerated string choices."""
+ @staticmethod
def _generate_next_value_(name, start, count, last_values):
return name