From 92c2d933130ee304fe42497b1f11672a3ac6b4fa Mon Sep 17 00:00:00 2001 From: John Parton Date: Thu, 15 Aug 2024 10:31:21 -0500 Subject: [PATCH] Allow text choices being directly assigned as choices. --- django-stubs/db/models/fields/__init__.pyi | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/django-stubs/db/models/fields/__init__.pyi b/django-stubs/db/models/fields/__init__.pyi index 89cc66d3e..4cb1af1d8 100644 --- a/django-stubs/db/models/fields/__init__.pyi +++ b/django-stubs/db/models/fields/__init__.pyi @@ -8,7 +8,7 @@ from typing_extensions import Literal, Self from django.core.checks import CheckMessage from django.core.exceptions import FieldDoesNotExist as FieldDoesNotExist -from django.db.models import Model +from django.db.models import Model, TextChoices from django.db.models.expressions import Col, Combinable from django.db.models.query_utils import RegisterLookupMixin from django.forms import Widget @@ -679,7 +679,8 @@ class CharField(Generic[_C], Field[_C | Combinable, _C]): unique_for_date: str | None = ..., unique_for_month: str | None = ..., unique_for_year: str | None = ..., - choices: Iterable[tuple[_C, str] | tuple[str, Iterable[tuple[_C, str]]]] = ..., + choices: Iterable[tuple[_C, str] | tuple[str, Iterable[tuple[_C, str]]]] + | type[TextChoices] = ..., help_text: str = ..., db_column: str | None = ..., db_comment: str | None = ..., @@ -706,7 +707,8 @@ class CharField(Generic[_C], Field[_C | Combinable, _C]): unique_for_date: str | None = ..., unique_for_month: str | None = ..., unique_for_year: str | None = ..., - choices: Iterable[tuple[_C, str] | tuple[str, Iterable[tuple[_C, str]]]] = ..., + choices: Iterable[tuple[_C, str] | tuple[str, Iterable[tuple[_C, str]]]] + | type[TextChoices] = ..., help_text: str = ..., db_column: str | None = ..., db_comment: str | None = ...,