From f75e52b8a817cdbe72fc0c214bc6ea49701aaa1f Mon Sep 17 00:00:00 2001 From: H4rryK4ne <39696020+H4rryK4ne@users.noreply.github.com> Date: Thu, 5 Dec 2024 20:25:00 +0100 Subject: [PATCH] Extend _AllLimitChoicesTo (#2456) allow callables which return _LimitChoicesTo Co-authored-by: Martin Reidemeister --- 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]