Add ValidationError type hints (#767)

This commit is contained in:
Marti Raudsepp
2021-12-08 14:09:20 +02:00
committed by GitHub
parent e5361f1e04
commit 79d34d6f46

View File

@@ -1,4 +1,4 @@
from typing import Any, Dict, Iterator, List, Mapping, Optional, Tuple, Union from typing import Any, Dict, Iterator, List, Literal, Mapping, Optional, Tuple, Union
from django.forms.utils import ErrorDict from django.forms.utils import ErrorDict
@@ -24,15 +24,20 @@ class MiddlewareNotUsed(Exception): ...
class ImproperlyConfigured(Exception): ... class ImproperlyConfigured(Exception): ...
class FieldError(Exception): ... class FieldError(Exception): ...
NON_FIELD_ERRORS: str NON_FIELD_ERRORS: Literal["__all__"]
class ValidationError(Exception): class ValidationError(Exception):
error_dict: Any = ... error_dict: Dict[str, ValidationError] = ...
error_list: Any = ... error_list: List[ValidationError] = ...
message: Any = ... message: str = ...
code: Any = ... code: Optional[str] = ...
params: Any = ... params: Optional[Mapping[str, Any]] = ...
def __init__(self, message: Any, code: Optional[str] = ..., params: Optional[Mapping[str, Any]] = ...) -> None: ... def __init__(
self,
message: Union[str, ValidationError, Dict[str, Any], List[Any]],
code: Optional[str] = ...,
params: Optional[Mapping[str, Any]] = ...,
) -> None: ...
@property @property
def message_dict(self) -> Dict[str, List[str]]: ... def message_dict(self) -> Dict[str, List[str]]: ...
@property @property