Skip to content

Commit a2a3543

Browse files
authored
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.
1 parent 88793ee commit a2a3543

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

django-stubs/db/models/fields/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ BLANK_CHOICE_DASH: List[Tuple[str, str]] = ...
4141
_Choice = Tuple[Any, Any]
4242
_ChoiceNamedGroup = Tuple[str, Iterable[_Choice]]
4343
_FieldChoices = Iterable[Union[_Choice, _ChoiceNamedGroup]]
44-
_ChoicesList = List[Union[_Choice, _ChoiceNamedGroup]]
44+
_ChoicesList = Union[Sequence[_Choice], Sequence[_ChoiceNamedGroup]]
4545
_LimitChoicesTo = Union[Q, Dict[str, Any]]
4646

4747
class _ChoicesCallable(Protocol):

0 commit comments

Comments
 (0)