Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support lazy strings for form errors and ValidationError #1319

Merged
merged 1 commit into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion django-stubs/core/exceptions.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ NON_FIELD_ERRORS: Literal["__all__"]
class ValidationError(Exception):
error_dict: dict[str, list[ValidationError]]
error_list: list[ValidationError]
message: str
message: _StrOrPromise
code: str | None
params: dict[str, Any] | None
def __init__(
Expand Down
3 changes: 2 additions & 1 deletion django-stubs/forms/forms.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ from django.forms.fields import Field
from django.forms.renderers import BaseRenderer
from django.forms.utils import ErrorDict, ErrorList, _DataT, _FilesT
from django.forms.widgets import Media, MediaDefiningClass
from django.utils.functional import _StrOrPromise
from django.utils.safestring import SafeString

class DeclarativeFieldsMetaclass(MediaDefiningClass): ...
Expand Down Expand Up @@ -55,7 +56,7 @@ class BaseForm:
def as_ul(self) -> SafeString: ...
def as_p(self) -> SafeString: ...
def non_field_errors(self) -> ErrorList: ...
def add_error(self, field: str | None, error: ValidationError | str) -> None: ...
def add_error(self, field: str | None, error: ValidationError | _StrOrPromise) -> None: ...
def has_error(self, field: str | None, code: str | None = ...) -> bool: ...
def full_clean(self) -> None: ...
def clean(self) -> dict[str, Any] | None: ...
Expand Down