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.
This commit is contained in:
Petter Friberg
2022-09-19 12:17:17 +02:00
committed by GitHub
parent 88793ee3f7
commit a2a3543198

View File

@@ -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):