From a2a3543198c0ba3d98504fc529015130232fb0c4 Mon Sep 17 00:00:00 2001 From: Petter Friberg Date: Mon, 19 Sep 2022 12:17:17 +0200 Subject: [PATCH] Adjust `choices=` type variance for model fields (#1154) Avoid getting stuck in an invariance pit. I don't think it makes sense to mix two tuple with named group elements in same choices sequence(?). This also changes the outermost container type to `Sequence` as e.g. both `tuple` and `list` are supported. --- django-stubs/db/models/fields/__init__.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django-stubs/db/models/fields/__init__.pyi b/django-stubs/db/models/fields/__init__.pyi index 95e37c5..7be7510 100644 --- a/django-stubs/db/models/fields/__init__.pyi +++ b/django-stubs/db/models/fields/__init__.pyi @@ -41,7 +41,7 @@ BLANK_CHOICE_DASH: List[Tuple[str, str]] = ... _Choice = Tuple[Any, Any] _ChoiceNamedGroup = Tuple[str, Iterable[_Choice]] _FieldChoices = Iterable[Union[_Choice, _ChoiceNamedGroup]] -_ChoicesList = List[Union[_Choice, _ChoiceNamedGroup]] +_ChoicesList = Union[Sequence[_Choice], Sequence[_ChoiceNamedGroup]] _LimitChoicesTo = Union[Q, Dict[str, Any]] class _ChoicesCallable(Protocol):