Refs #32074 -- Used Enum.repr() format proposed for Python 3.10.
The Python's Steering Council decided to revert changes in the Enum
module (see https://bugs.python.org/issue44559) and moved them to
Python 3.11.
Follow up to 5d9b065d3f
.
Thanks Nick Pope for the review.
This commit is contained in:
parent
013a1824d3
commit
0250340e37
|
@ -4,7 +4,6 @@ from django.db.models.expressions import ExpressionList, F
|
|||
from django.db.models.indexes import IndexExpression
|
||||
from django.db.models.query_utils import Q
|
||||
from django.db.models.sql.query import Query
|
||||
from django.utils.version import PY310
|
||||
|
||||
__all__ = ['CheckConstraint', 'Deferrable', 'UniqueConstraint']
|
||||
|
||||
|
@ -86,10 +85,9 @@ class Deferrable(Enum):
|
|||
DEFERRED = 'deferred'
|
||||
IMMEDIATE = 'immediate'
|
||||
|
||||
# A similar format is used in Python 3.10+.
|
||||
if not PY310:
|
||||
# A similar format was proposed for Python 3.10.
|
||||
def __repr__(self):
|
||||
return '%s.%s' % (self.__class__.__qualname__, self._name_)
|
||||
return f'{self.__class__.__qualname__}.{self._name_}'
|
||||
|
||||
|
||||
class UniqueConstraint(BaseConstraint):
|
||||
|
|
|
@ -2,7 +2,6 @@ import enum
|
|||
from types import DynamicClassAttribute
|
||||
|
||||
from django.utils.functional import Promise
|
||||
from django.utils.version import PY310
|
||||
|
||||
__all__ = ['Choices', 'IntegerChoices', 'TextChoices']
|
||||
|
||||
|
@ -75,10 +74,9 @@ class Choices(enum.Enum, metaclass=ChoicesMeta):
|
|||
"""
|
||||
return str(self.value)
|
||||
|
||||
# A similar format is used in Python 3.10+.
|
||||
if not PY310:
|
||||
# A similar format was proposed for Python 3.10.
|
||||
def __repr__(self):
|
||||
return '%s.%s' % (self.__class__.__qualname__, self._name_)
|
||||
return f'{self.__class__.__qualname__}.{self._name_}'
|
||||
|
||||
|
||||
class IntegerChoices(int, Choices):
|
||||
|
|
Loading…
Reference in New Issue