From 5d357cb1055b1e60acb84631a8cad58a01bc4001 Mon Sep 17 00:00:00 2001 From: SaJH Date: Mon, 15 Apr 2024 21:01:23 +0900 Subject: [PATCH] [3.15] Add represent_timedelta, a function related to CustomScalar --- rest_framework-stubs/utils/encoders.pyi | 7 +++++++ scripts/stubtest/allowlist_todo.txt | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/rest_framework-stubs/utils/encoders.pyi b/rest_framework-stubs/utils/encoders.pyi index 9d88a9b58..a6e2a87c5 100644 --- a/rest_framework-stubs/utils/encoders.pyi +++ b/rest_framework-stubs/utils/encoders.pyi @@ -1,3 +1,10 @@ +import datetime import json +from yaml import Dumper, ScalarNode + class JSONEncoder(json.JSONEncoder): ... + +class CustomScalar: + @classmethod + def represent_timedelta(cls, dumper: Dumper, data: datetime.timedelta) -> ScalarNode: ... diff --git a/scripts/stubtest/allowlist_todo.txt b/scripts/stubtest/allowlist_todo.txt index 5ce812434..4e4e6bfdd 100644 --- a/scripts/stubtest/allowlist_todo.txt +++ b/scripts/stubtest/allowlist_todo.txt @@ -147,5 +147,4 @@ rest_framework.serializers.Field.__class_getitem__ rest_framework.serializers.ListSerializer.run_child_validation rest_framework.serializers.ModelSerializer.get_unique_together_constraints rest_framework.templatetags.rest_framework.optional_logout -rest_framework.utils.encoders.CustomScalar rest_framework.utils.field_mapping.get_unique_validators