From ebdf2bb61ce97bd6f2966e788a159ce11afd5ea8 Mon Sep 17 00:00:00 2001 From: Marti Raudsepp Date: Tue, 19 Mar 2024 15:56:40 +0200 Subject: [PATCH 1/2] [3.15] Add ValidationError params argument & default_params attribute --- rest_framework-stubs/exceptions.pyi | 6 +++++- scripts/stubtest/allowlist_todo.txt | 4 ---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/rest_framework-stubs/exceptions.pyi b/rest_framework-stubs/exceptions.pyi index 53a6d397f..cc5eed919 100644 --- a/rest_framework-stubs/exceptions.pyi +++ b/rest_framework-stubs/exceptions.pyi @@ -1,5 +1,5 @@ from collections.abc import Mapping, Sequence -from typing import Any +from typing import Any, ClassVar from django.http import HttpRequest, JsonResponse from django_stubs_ext import StrOrPromise @@ -43,6 +43,10 @@ class APIException(Exception): class ValidationError(APIException): # ValidationError wraps `detail` in a list if it's not already a list/dict. detail: list[_Detail] | dict[str, _Detail] + default_params: ClassVar[Mapping[str, Any]] + def __init__( + self, detail: _Detail | None = ..., code: str | None = ..., params: Mapping[str, Any] | None = ... + ) -> None: ... class ParseError(APIException): ... class AuthenticationFailed(APIException): ... diff --git a/scripts/stubtest/allowlist_todo.txt b/scripts/stubtest/allowlist_todo.txt index 19c8e6464..b3f0b7077 100644 --- a/scripts/stubtest/allowlist_todo.txt +++ b/scripts/stubtest/allowlist_todo.txt @@ -140,8 +140,6 @@ rest_framework.views.GenericView rest_framework.RemovedInDRF317Warning rest_framework.authtoken.migrations.0004_alter_tokenproxy_options rest_framework.compat.distinct -rest_framework.exceptions.ValidationError.__init__ -rest_framework.exceptions.ValidationError.default_params rest_framework.fields.DecimalField.__init__ rest_framework.fields.Field.__class_getitem__ rest_framework.fields.logger @@ -160,8 +158,6 @@ rest_framework.serializers.LIST_SERIALIZER_KWARGS_REMOVE rest_framework.serializers.ListSerializer.run_child_validation rest_framework.serializers.ModelSerializer.get_unique_together_constraints rest_framework.serializers.Serializer.set_value -rest_framework.serializers.ValidationError.__init__ -rest_framework.serializers.ValidationError.default_params rest_framework.templatetags.rest_framework.optional_logout rest_framework.utils.encoders.CustomScalar rest_framework.utils.field_mapping.get_unique_validators From 3305102a1b78fc920d9ed0a2c520b3dc17e11d2d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 19 Mar 2024 13:56:57 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks --- rest_framework-stubs/exceptions.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework-stubs/exceptions.pyi b/rest_framework-stubs/exceptions.pyi index cc5eed919..a331e3715 100644 --- a/rest_framework-stubs/exceptions.pyi +++ b/rest_framework-stubs/exceptions.pyi @@ -45,7 +45,7 @@ class ValidationError(APIException): detail: list[_Detail] | dict[str, _Detail] default_params: ClassVar[Mapping[str, Any]] def __init__( - self, detail: _Detail | None = ..., code: str | None = ..., params: Mapping[str, Any] | None = ... + self, detail: _Detail | None = ..., code: str | None = ..., params: Mapping[str, Any] | None = ... ) -> None: ... class ParseError(APIException): ...