Skip to content

Commit

Permalink
Fix BaseModelForm, ErrorList, ErrorDict __init__(renderer=) parameter (
Browse files Browse the repository at this point in the history
…#1690)

Adds ErrorList and ErrorDict __init__'s

Was not able to remove the __init__ from the allowlist, as there seems to be an issue with ErrorList.

Added basic ErrorDict constructor signature.
  • Loading branch information
GabDug committed Oct 18, 2023
1 parent bcf6356 commit 323b105
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion django-stubs/forms/models.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,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: ...
Expand Down
2 changes: 2 additions & 0 deletions django-stubs/forms/utils.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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]: ...

Expand All @@ -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]]: ...
Expand Down
2 changes: 0 additions & 2 deletions scripts/stubtest/allowlist_todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2093,8 +2093,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
Expand Down

0 comments on commit 323b105

Please sign in to comment.