From cefb479c6a4989991ad66c245420bfdedf11b661 Mon Sep 17 00:00:00 2001 From: Viicos <65306057+Viicos@users.noreply.github.com> Date: Wed, 14 Feb 2024 18:25:52 +0100 Subject: [PATCH 1/2] [5.0] Update `core.paginator` --- django-stubs/core/paginator.pyi | 5 ++++- scripts/stubtest/allowlist_todo_django50.txt | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/django-stubs/core/paginator.pyi b/django-stubs/core/paginator.pyi index c6ef37337..385b7aaac 100644 --- a/django-stubs/core/paginator.pyi +++ b/django-stubs/core/paginator.pyi @@ -1,7 +1,7 @@ from collections.abc import Iterable, Iterator, Sequence, Sized from typing import ClassVar, Generic, Protocol, TypeVar, overload, type_check_only -from django.utils.functional import _StrPromise, cached_property +from django.utils.functional import _StrOrPromise, _StrPromise, cached_property class UnorderedObjectListWarning(RuntimeWarning): ... class InvalidPage(Exception): ... @@ -19,6 +19,8 @@ class _SupportsPagination(Protocol[_T], Sized, Iterable): class Paginator(Generic[_T]): ELLIPSIS: ClassVar[_StrPromise] + default_error_messages: ClassVar[dict[str, _StrPromise]] + error_messages: dict[str, _StrOrPromise] object_list: _SupportsPagination[_T] per_page: int orphans: int @@ -29,6 +31,7 @@ class Paginator(Generic[_T]): per_page: int | str, orphans: int = ..., allow_empty_first_page: bool = ..., + error_messages: dict[str, _StrOrPromise] | None = ..., ) -> None: ... def __iter__(self) -> Iterator[Page[_T]]: ... def validate_number(self, number: int | float | str) -> int: ... diff --git a/scripts/stubtest/allowlist_todo_django50.txt b/scripts/stubtest/allowlist_todo_django50.txt index 5410561ae..5e7476e57 100644 --- a/scripts/stubtest/allowlist_todo_django50.txt +++ b/scripts/stubtest/allowlist_todo_django50.txt @@ -124,8 +124,6 @@ django.core.handlers.asgi.ASGIHandler.run_get_response django.core.handlers.asgi.get_script_prefix django.core.management.commands.inspectdb.Command.normalize_table_name django.core.management.commands.optimizemigration -django.core.paginator.Paginator.__init__ -django.core.paginator.Paginator.default_error_messages django.core.serializers.base.PickleSerializer django.core.validators.StepValueValidator.__init__ django.db.backends.base.base.timezone_constructor From 69dcceb4d28874aeaffedf67aa9cb810e7f08e50 Mon Sep 17 00:00:00 2001 From: Viicos <65306057+Viicos@users.noreply.github.com> Date: Thu, 15 Feb 2024 13:39:11 +0100 Subject: [PATCH 2/2] Feedback --- django-stubs/core/paginator.pyi | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/django-stubs/core/paginator.pyi b/django-stubs/core/paginator.pyi index 385b7aaac..6e86f5cb9 100644 --- a/django-stubs/core/paginator.pyi +++ b/django-stubs/core/paginator.pyi @@ -1,7 +1,8 @@ from collections.abc import Iterable, Iterator, Sequence, Sized from typing import ClassVar, Generic, Protocol, TypeVar, overload, type_check_only -from django.utils.functional import _StrOrPromise, _StrPromise, cached_property +from django.db.fields import _ErrorMessagesDict +from django.utils.functional import _StrPromise, cached_property class UnorderedObjectListWarning(RuntimeWarning): ... class InvalidPage(Exception): ... @@ -19,8 +20,8 @@ class _SupportsPagination(Protocol[_T], Sized, Iterable): class Paginator(Generic[_T]): ELLIPSIS: ClassVar[_StrPromise] - default_error_messages: ClassVar[dict[str, _StrPromise]] - error_messages: dict[str, _StrOrPromise] + default_error_messages: ClassVar[_ErrorMessagesDict] + error_messages: _ErrorMessagesDict object_list: _SupportsPagination[_T] per_page: int orphans: int @@ -31,7 +32,7 @@ class Paginator(Generic[_T]): per_page: int | str, orphans: int = ..., allow_empty_first_page: bool = ..., - error_messages: dict[str, _StrOrPromise] | None = ..., + error_messages: _ErrorMessagesDict | None = ..., ) -> None: ... def __iter__(self) -> Iterator[Page[_T]]: ... def validate_number(self, number: int | float | str) -> int: ...