1+ import typing as t
2+ from typing_extensions import Annotated
13from django .db import models
2- from django_enum import EnumField , IntegerChoices , TextChoices
3- from enum_properties import p , s
4+ from django_enum import EnumField
5+ from django_enum .choices import IntegerChoices , TextChoices
6+ from enum_properties import Symmetric , s
47
58try :
69 from django .utils .decorators import classproperty
@@ -12,7 +15,10 @@ class EnumTester(models.Model):
1215 class NotAnEnum :
1316 pass
1417
15- class Color (TextChoices , s ("rgb" ), s ("hex" , case_fold = True )):
18+ class Color (TextChoices ):
19+ rgb : Annotated [t .Tuple [int , int , int ], Symmetric ()]
20+ hex : Annotated [str , Symmetric (case_fold = True )]
21+
1622 # name value label rgb hex
1723 RED = "R" , "Red" , (1 , 0 , 0 ), "ff0000"
1824 GREEN = "G" , "Green" , (0 , 1 , 0 ), "00ff00"
@@ -22,13 +28,16 @@ class Color(TextChoices, s("rgb"), s("hex", case_fold=True)):
2228 def class_name (cls ):
2329 return cls .__name__
2430
25- class MapBoxStyle (IntegerChoices , s ( "slug" , case_fold = True ), p ( "version" ) ):
31+ class MapBoxStyle (IntegerChoices ):
2632 """
2733 https://docs.mapbox.com/api/maps/styles/
2834 """
2935
3036 _symmetric_builtins_ = ["name" , "uri" , "label" ]
3137
38+ slug : Annotated [str , Symmetric (case_fold = True )]
39+ version : int
40+
3241 # name value label slug version
3342 STREETS = 1 , "Streets" , "streets" , 11
3443 OUTDOORS = 2 , "Outdoors" , "outdoors" , 11
@@ -54,9 +63,12 @@ def docs(cls):
5463 # def __str__(self):
5564 # return self.uri
5665
57- class AddressRoute (TextChoices , s ( "alt" , case_fold = True ), p ( "str" ) ):
66+ class AddressRoute (TextChoices ):
5867 _symmetric_builtins_ = [s ("name" , case_fold = True )]
5968
69+ alt : Annotated [t .List [str ], Symmetric (case_fold = True )]
70+ str : str
71+
6072 # name value alt
6173 ALLEY = (
6274 "ALY" ,
0 commit comments