One of my methods takes a status
argument that's used in a filter()
.
This argument is related to a model field defined like this :
STATUS_CHOICES = (
(1, _("draft")),
(2, _("private")),
(3, _("published")),
)
class MyModel(Model):
status = models.PositiveSmallIntegerField(_("status"), choices=STATUS_CHOICES, default=1)
I'd like to use Python's type hints in order to make its definition clearer.
I could probably do something like :
def my_method(status: int):
...
But the status has to be included in STATUS_CHOICES
.
Can I make this hint more restrictive and limited to STATUS_CHOICES
values?