From c4bb911e1de3a0dff71d170df81c9af4c9a72178 Mon Sep 17 00:00:00 2001 From: Alessio Bogon <778703+youtux@users.noreply.github.com> Date: Sun, 17 Nov 2024 11:31:45 +0100 Subject: [PATCH] Fix signature of `ModelAdmin.construct_change_message` (#2444) * Fix signature of `ModelAdmin.construct_change_message` The `form` argument was incorrectly typed. * Fix annotations for `utils.construct_change_message` --- django-stubs/contrib/admin/options.pyi | 3 +-- django-stubs/contrib/admin/utils.pyi | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/django-stubs/contrib/admin/options.pyi b/django-stubs/contrib/admin/options.pyi index e4a98589a..ce6eaed75 100644 --- a/django-stubs/contrib/admin/options.pyi +++ b/django-stubs/contrib/admin/options.pyi @@ -7,7 +7,6 @@ from django.contrib.admin.filters import FieldListFilter, ListFilter from django.contrib.admin.models import LogEntry from django.contrib.admin.sites import AdminSite from django.contrib.admin.views.main import ChangeList -from django.contrib.auth.forms import AdminPasswordChangeForm from django.contrib.contenttypes.models import ContentType from django.core.checks.messages import CheckMessage from django.core.paginator import Paginator @@ -225,7 +224,7 @@ class ModelAdmin(BaseModelAdmin[_ModelT]): def _get_edited_object_pks(self, request: HttpRequest, prefix: str) -> list[str]: ... def _get_list_editable_queryset(self, request: HttpRequest, prefix: str) -> QuerySet[_ModelT]: ... def construct_change_message( - self, request: HttpRequest, form: AdminPasswordChangeForm, formsets: Iterable[BaseFormSet], add: bool = ... + self, request: HttpRequest, form: forms.Form, formsets: Iterable[BaseFormSet], add: bool = ... ) -> list[dict[str, dict[str, list[str]]]]: ... def message_user( self, diff --git a/django-stubs/contrib/admin/utils.pyi b/django-stubs/contrib/admin/utils.pyi index fd3a30398..34acd72fd 100644 --- a/django-stubs/contrib/admin/utils.pyi +++ b/django-stubs/contrib/admin/utils.pyi @@ -7,14 +7,13 @@ from uuid import UUID from _typeshed import Unused from django.contrib.admin.options import BaseModelAdmin from django.contrib.admin.sites import AdminSite -from django.contrib.auth.forms import AdminPasswordChangeForm from django.db.models.base import Model from django.db.models.deletion import Collector from django.db.models.fields import Field, reverse_related from django.db.models.options import Options from django.db.models.query import QuerySet from django.db.models.query_utils import Q -from django.forms.forms import BaseForm +from django.forms.forms import BaseForm, Form from django.forms.formsets import BaseFormSet from django.http.request import HttpRequest from django.utils.datastructures import _IndexableCollection @@ -100,5 +99,5 @@ def get_model_from_relation(field: Field | reverse_related.ForeignObjectRel) -> def reverse_field_path(model: type[Model], path: str) -> tuple[type[Model], str]: ... def get_fields_from_path(model: type[Model], path: str) -> list[Field]: ... def construct_change_message( - form: AdminPasswordChangeForm, formsets: Iterable[BaseFormSet], add: bool + form: Form, formsets: Iterable[BaseFormSet], add: bool ) -> list[dict[str, dict[str, list[str]]]]: ...