Skip to content

Commit

Permalink
Extend _AllLimitChoicesTo (#2456)
Browse files Browse the repository at this point in the history
allow callables which return _LimitChoicesTo

Co-authored-by: Martin Reidemeister <m.reidemeister@werkzeugbau-akademie.de>
  • Loading branch information
H4rryK4ne and Martin Reidemeister authored Dec 5, 2024
1 parent 16eb5a8 commit f75e52b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion django-stubs/db/models/fields/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ BLANK_CHOICE_DASH: list[tuple[str, str]]

_ChoicesList: TypeAlias = Sequence[_Choice] | Sequence[_ChoiceNamedGroup]
_LimitChoicesTo: TypeAlias = Q | dict[str, Any]
_LimitChoicesToCallable: TypeAlias = Callable[[], _LimitChoicesTo]

_F = TypeVar("_F", bound=Field, covariant=True)

Expand All @@ -39,7 +40,7 @@ class _FieldDescriptor(Protocol[_F]):
@property
def field(self) -> _F: ...

_AllLimitChoicesTo: TypeAlias = _LimitChoicesTo | _ChoicesCallable # noqa: PYI047
_AllLimitChoicesTo: TypeAlias = _LimitChoicesTo | _LimitChoicesToCallable | _ChoicesCallable # noqa: PYI047
_ErrorMessagesMapping: TypeAlias = Mapping[str, _StrOrPromise]
_ErrorMessagesDict: TypeAlias = dict[str, _StrOrPromise]

Expand Down

0 comments on commit f75e52b

Please sign in to comment.