From 331042d1c73e48adc3f7028c3887c0a2f7c66dac Mon Sep 17 00:00:00 2001 From: David Cain Date: Sat, 13 Nov 2021 11:56:27 -0800 Subject: [PATCH] Add signature for Django 3.2 TimestampSigner (#751) Django 3.2 introduced two new methods: `sign_object` and `unsign_object` which can sign/unsign "complex data structures" such as lists, tuples, dictionaries: https://docs.djangoproject.com/en/3.2/topics/signing/#django.core.signing.TimestampSigner Because the methods take an arbitrary serializer (a JSON serializer by default, but not guaranteed), we cannot be sure of the type of `obj`. --- django-stubs/core/signing.pyi | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/django-stubs/core/signing.pyi b/django-stubs/core/signing.pyi index 4671602..4eb578a 100644 --- a/django-stubs/core/signing.pyi +++ b/django-stubs/core/signing.pyi @@ -51,3 +51,15 @@ class Signer: class TimestampSigner(Signer): def timestamp(self) -> str: ... def unsign(self, value: str, max_age: Optional[Union[int, timedelta]] = ...) -> str: ... + def sign_object( + self, + obj: Any, + serializer: Type[Serializer] = ..., + compress: bool = ..., + ) -> str: ... + def unsign_object( + self, + signed_obj: str, + serializer: Type[Serializer] = ..., + max_age: Optional[Union[int, timedelta]] = ..., + ) -> Any: ...