From 843b657d09032bc747d1d6a5bfe53b8389c3463b Mon Sep 17 00:00:00 2001 From: Martin Reidemeister Date: Thu, 5 Dec 2024 16:31:10 +0100 Subject: [PATCH] Extend _AllLimitChoicesTo allow callables which return _LimitChoicesTo --- django-stubs/db/models/fields/__init__.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/django-stubs/db/models/fields/__init__.pyi b/django-stubs/db/models/fields/__init__.pyi index 68a6c5678..ef4830b96 100644 --- a/django-stubs/db/models/fields/__init__.pyi +++ b/django-stubs/db/models/fields/__init__.pyi @@ -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) @@ -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]