From b66572e8d9a0b57720dbf5e10fa49e98e4e0115f Mon Sep 17 00:00:00 2001 From: Zixuan James Li Date: Mon, 29 Aug 2022 18:45:57 -0400 Subject: [PATCH] Broaden type annotation for ValidationError to accept lazystr. Signed-off-by: Zixuan James Li --- django-stubs/core/exceptions.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/django-stubs/core/exceptions.pyi b/django-stubs/core/exceptions.pyi index 43211be6e..9b0810e43 100644 --- a/django-stubs/core/exceptions.pyi +++ b/django-stubs/core/exceptions.pyi @@ -1,5 +1,6 @@ from typing import Any, Dict, Iterator, List, Optional, Tuple, Union +from django.utils.functional import _StrPromise from typing_extensions import Literal class FieldDoesNotExist(Exception): ... @@ -35,7 +36,7 @@ class ValidationError(Exception): def __init__( self, # Accepts arbitrarily nested data structure, mypy doesn't allow describing it accurately. - message: Union[str, ValidationError, Dict[str, Any], List[Any]], + message: Union[str, _StrPromise, ValidationError, Dict[str, Any], List[Any]], code: Optional[str] = ..., params: Optional[Dict[str, Any]] = ..., ) -> None: ...