From b56596d0d37c704efcceb28a6709ffd1fc736348 Mon Sep 17 00:00:00 2001 From: Marti Raudsepp Date: Mon, 6 Feb 2023 19:03:59 +0200 Subject: [PATCH] Add support for ValidationError argument params This isn't part of released django-rest-framework, but has been merged upstream. Upstream PR: https://github.com/encode/django-rest-framework/pull/8863 --- rest_framework-stubs/exceptions.pyi | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/rest_framework-stubs/exceptions.pyi b/rest_framework-stubs/exceptions.pyi index 9af1352f3..70b5521c1 100644 --- a/rest_framework-stubs/exceptions.pyi +++ b/rest_framework-stubs/exceptions.pyi @@ -1,12 +1,11 @@ from collections.abc import Sequence from typing import Any -from typing_extensions import TypeAlias - from django.http import HttpRequest, JsonResponse from django_stubs_ext import StrOrPromise from rest_framework.renderers import BaseRenderer from rest_framework.request import Request +from typing_extensions import TypeAlias def _get_error_details(data: Any, default_code: str | None = ...) -> Any: ... def _get_codes(detail: Any) -> Any: ... @@ -28,7 +27,12 @@ class APIException(Exception): def get_codes(self) -> Any: ... def get_full_details(self) -> Any: ... -class ValidationError(APIException): ... +class ValidationError(APIException): + default_params: Mapping[str, Any] + def __init__( + self, detail: _Detail | None = ..., code: str | None = ..., params: Mapping[str, Any] | None = ... + ) -> None: ... + class ParseError(APIException): ... class AuthenticationFailed(APIException): ... class NotAuthenticated(APIException): ...