#32460: TextChoices/IntegerChoices can not have a member with name `label`
-------------------------------------+-------------------------------------
               Reporter:  elonzh     |          Owner:  nobody
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  3.0
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:  Choices
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 {{{
 import enum
 from django.db.models import TextChoices, IntegerChoices


 class A(enum.Enum):
     label = "label"


 print("case A, builtin Enum type:", A.label)


 class B(TextChoices):
     LABEL = "label"


 print("case B, TextChoices with a choice `LABEL`:", B.LABEL)

 try:
     class C(TextChoices):
         label = "label"

 except Exception as e:
     print("case C, TextChoices with a choice `label`:", e)


 try:
     class D(IntegerChoices):
         label = 0

 except Exception as e:
     print("case D, IntegerChoices with a choice `label`:", e)

 }}}


 output:


 {{{
 case A, builtin Enum type: A.label
 case B, TextChoices with a choice `LABEL`: label
 case C, TextChoices with a choice `label`: Cannot reassign members.
 case D, IntegerChoices with a choice `label`: Cannot reassign members.
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32460>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.a5044c6ff4f11b3d8c5ebf5d234020dc%40djangoproject.com.

Reply via email to