From 41364ba5e667e81fac2b1d2ec0b0b3ce915b1092 Mon Sep 17 00:00:00 2001 From: Gabriel Dugny Date: Thu, 7 Sep 2023 20:24:34 +0200 Subject: [PATCH] Fixes #1642 BaseModelForm.__init__ renderer type --- django-stubs/forms/models.pyi | 2 +- django-stubs/forms/utils.pyi | 2 ++ scripts/stubtest/allowlist_todo.txt | 2 -- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/django-stubs/forms/models.pyi b/django-stubs/forms/models.pyi index b93303066..c26c70020 100644 --- a/django-stubs/forms/models.pyi +++ b/django-stubs/forms/models.pyi @@ -89,7 +89,7 @@ class BaseModelForm(Generic[_M], BaseForm): empty_permitted: bool = ..., instance: _M | None = ..., use_required_attribute: bool | None = ..., - renderer: BaseRenderer = ..., + renderer: BaseRenderer | None = ..., ) -> None: ... def validate_unique(self) -> None: ... def save(self, commit: bool = ...) -> _M: ... diff --git a/django-stubs/forms/utils.pyi b/django-stubs/forms/utils.pyi index 5b6bf46cd..e367727f3 100644 --- a/django-stubs/forms/utils.pyi +++ b/django-stubs/forms/utils.pyi @@ -46,6 +46,7 @@ class ErrorDict(dict[str, ErrorList], RenderableErrorMixin): template_name_ul: str renderer: BaseRenderer + def __init__(self, *args: Any, renderer: BaseRenderer | None = None, **kwargs: Any): ... def as_data(self) -> dict[str, list[ValidationError]]: ... def get_json_data(self, escape_html: bool = ...) -> dict[str, Any]: ... @@ -59,6 +60,7 @@ class ErrorList(UserList[ValidationError | _StrOrPromise], RenderableErrorMixin) self, initlist: ErrorList | Sequence[str | Exception] | None = ..., error_class: str | None = ..., + renderer: BaseRenderer | None = ..., ) -> None: ... def as_data(self) -> list[ValidationError]: ... def get_json_data(self, escape_html: bool = ...) -> list[dict[str, str]]: ... diff --git a/scripts/stubtest/allowlist_todo.txt b/scripts/stubtest/allowlist_todo.txt index 329d10e2b..9d22f51a5 100644 --- a/scripts/stubtest/allowlist_todo.txt +++ b/scripts/stubtest/allowlist_todo.txt @@ -2171,8 +2171,6 @@ django.forms.renderers.DjangoDivFormRenderer django.forms.renderers.EngineMixin.engine django.forms.renderers.Jinja2.backend django.forms.utils.DEFAULT_TEMPLATE_DEPRECATION_MSG -django.forms.utils.ErrorDict.__init__ -django.forms.utils.ErrorList.__init__ django.forms.widgets.ChoiceWidget.__deepcopy__ django.forms.widgets.ChoiceWidget.subwidgets django.forms.widgets.ChoiceWidget.template_name