Skip to content

Commit 1c482dc

Browse files
authored
support str or promise in errors (#1319)
1 parent ab8bf7f commit 1c482dc

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

django-stubs/core/exceptions.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ NON_FIELD_ERRORS: Literal["__all__"]
3131
class ValidationError(Exception):
3232
error_dict: dict[str, list[ValidationError]]
3333
error_list: list[ValidationError]
34-
message: str
34+
message: _StrOrPromise
3535
code: str | None
3636
params: dict[str, Any] | None
3737
def __init__(

django-stubs/forms/forms.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ from django.forms.fields import Field
77
from django.forms.renderers import BaseRenderer
88
from django.forms.utils import ErrorDict, ErrorList, _DataT, _FilesT
99
from django.forms.widgets import Media, MediaDefiningClass
10+
from django.utils.functional import _StrOrPromise
1011
from django.utils.safestring import SafeString
1112

1213
class DeclarativeFieldsMetaclass(MediaDefiningClass): ...
@@ -55,7 +56,7 @@ class BaseForm:
5556
def as_ul(self) -> SafeString: ...
5657
def as_p(self) -> SafeString: ...
5758
def non_field_errors(self) -> ErrorList: ...
58-
def add_error(self, field: str | None, error: ValidationError | str) -> None: ...
59+
def add_error(self, field: str | None, error: ValidationError | _StrOrPromise) -> None: ...
5960
def has_error(self, field: str | None, code: str | None = ...) -> bool: ...
6061
def full_clean(self) -> None: ...
6162
def clean(self) -> dict[str, Any] | None: ...

0 commit comments

Comments
 (0)