From 7e363722e7bc4fd1118572e3c49669bc46fccb74 Mon Sep 17 00:00:00 2001 From: George Kettleborough Date: Sun, 25 Feb 2024 02:04:00 +0000 Subject: [PATCH] Add new model field choices options (#229) I wanted to add the callable option but noticed the mapping option was added too. --- django-stubs/db/models/fields/__init__.pyi | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/django-stubs/db/models/fields/__init__.pyi b/django-stubs/db/models/fields/__init__.pyi index 5f334e35b..326f168a2 100644 --- a/django-stubs/db/models/fields/__init__.pyi +++ b/django-stubs/db/models/fields/__init__.pyi @@ -3,7 +3,7 @@ import ipaddress import uuid from collections.abc import Callable, Iterable, Sequence from datetime import date, datetime, time, timedelta -from typing import Any, Generic, TypeVar, overload +from typing import Any, Generic, Mapping, TypeVar, overload from typing_extensions import Literal, Self from django.core.checks import CheckMessage @@ -17,7 +17,9 @@ BLANK_CHOICE_DASH: list[tuple[str, str]] = ... _Choice = tuple[Any, str] _ChoiceNamedGroup = tuple[str, Iterable[_Choice]] -_FieldChoices = Iterable[_Choice | _ChoiceNamedGroup] +_ChoicesMapping = Mapping[Any, str | Mapping[Any, str]] +_LiteralFieldChoices = Iterable[_Choice | _ChoiceNamedGroup] | _ChoicesMapping +_FieldChoices = _LiteralFieldChoices | Callable[[], _LiteralFieldChoices] _ValidatorCallable = Callable[..., None] _ErrorMessagesToOverride = dict[str, Any]