From 5bf5fbb3fe05d6815eea68b267450a7b33bb7eba Mon Sep 17 00:00:00 2001 From: Serhii Tereshchenko Date: Sat, 14 Sep 2024 17:30:25 +0300 Subject: [PATCH] fix: Use dict[str, Any] for validated_data (#49) > TODO(sbdchd): figure out how hard it would be to make this return a dict[str, Any] Turned out not hard at all ;) --- rest_framework-stubs/serializers.pyi | 6 +++--- rest_framework-stubs/test.pyi | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rest_framework-stubs/serializers.pyi b/rest_framework-stubs/serializers.pyi index b3e0128e9..13eb2c805 100644 --- a/rest_framework-stubs/serializers.pyi +++ b/rest_framework-stubs/serializers.pyi @@ -135,7 +135,7 @@ class Serializer(BaseSerializer, metaclass=SerializerMetaclass): def get_initial(self) -> Any: ... fields: Any def get_fields(self) -> dict[str, Field[Any, Any, Any, Any]]: ... - def validate(self, attrs: Any) -> Any: ... + def validate(self, attrs: dict[str, Any]) -> dict[str, Any]: ... def __iter__(self) -> Iterator[str]: ... def __getitem__(self, key: str) -> BoundField: ... def _read_only_defaults(self) -> dict[str, Any]: ... @@ -219,8 +219,8 @@ class ModelSerializer(Serializer, BaseSerializer): allow_null: bool = ..., allow_empty: bool = ..., ): ... - def update(self, instance: Any, validated_data: Any) -> Any: ... - def create(self, validated_data: Any) -> Any: ... + def update(self, instance: Any, validated_data: dict[str, Any]) -> Any: ... + def create(self, validated_data: dict[str, Any]) -> Any: ... def save(self, **kwargs: Any) -> Any: ... def to_representation(self, instance: Any) -> Any: ... def get_field_names( diff --git a/rest_framework-stubs/test.pyi b/rest_framework-stubs/test.pyi index 88695594a..f0177bbdc 100644 --- a/rest_framework-stubs/test.pyi +++ b/rest_framework-stubs/test.pyi @@ -127,7 +127,7 @@ class ForceAuthClientHandler(ClientHandler): def __init__(self, *args: Any, **kwargs: Any): ... def get_response(self, request: Request) -> Response: ... # type: ignore[override] -class APIClient(APIRequestFactory, DjangoClient): +class APIClient(APIRequestFactory, DjangoClient): # pyright: ignore[reportIncompatibleMethodOverride] handler: Any = ... def credentials(self, **kwargs: Any) -> Any: ... def force_authenticate(self, user: Any | None = ..., token: Token | None = ...) -> None: ...