diff --git a/django-stubs/core/signing.pyi b/django-stubs/core/signing.pyi index dba7aa20d..494437d6e 100644 --- a/django-stubs/core/signing.pyi +++ b/django-stubs/core/signing.pyi @@ -1,12 +1,18 @@ from datetime import timedelta -from typing import Any, Protocol, type_check_only +from typing import Any, Protocol, overload, type_check_only + +from typing_extensions import deprecated + +BASE62_ALPHABET: str class BadSignature(Exception): ... class SignatureExpired(BadSignature): ... +def b62_encode(s: int) -> str: ... +def b62_decode(s: str) -> int: ... def b64_encode(s: bytes) -> bytes: ... def b64_decode(s: bytes) -> bytes: ... -def base64_hmac(salt: str, value: bytes | str, key: bytes | str, algorithm: str = ...) -> str: ... +def base64_hmac(salt: bytes | str, value: bytes | str, key: bytes | str, algorithm: str = ...) -> str: ... def get_cookie_signer(salt: str = ...) -> TimestampSigner: ... @type_check_only class Serializer(Protocol): @@ -20,31 +26,47 @@ class JSONSerializer: def dumps( obj: Any, key: bytes | str | None = ..., - salt: str = ..., + salt: bytes | str = ..., serializer: type[Serializer] = ..., compress: bool = ..., ) -> str: ... def loads( s: str, key: bytes | str | None = ..., - salt: str = ..., + salt: bytes | str = ..., serializer: type[Serializer] = ..., max_age: int | timedelta | None = ..., + fallback_keys: list[str | bytes] | None = ..., ) -> Any: ... class Signer: - key: str + key: bytes | str + fallback_keys: list[bytes | str] sep: str - salt: str + salt: bytes | str algorithm: str + @overload + def __init__( + self, + *, + key: bytes | str | None = ..., + sep: str = ..., + salt: bytes | str | None = ..., + algorithm: str | None = ..., + fallback_keys: list[bytes | str] | None = ..., + ) -> None: ... + @overload + @deprecated("Passing positional arguments to Signer is deprecated and will be removed in Django 5.1") def __init__( self, + *args: Any, key: bytes | str | None = ..., sep: str = ..., - salt: str | None = ..., + salt: bytes | str | None = ..., algorithm: str | None = ..., + fallback_keys: list[bytes | str] | None = ..., ) -> None: ... - def signature(self, value: bytes | str) -> str: ... + def signature(self, value: bytes | str, key: bytes | str | None = ...) -> str: ... def sign(self, value: str) -> str: ... def unsign(self, signed_value: str) -> str: ... def sign_object( diff --git a/scripts/stubtest/allowlist_todo.txt b/scripts/stubtest/allowlist_todo.txt index 72a8467b5..18ee516c0 100644 --- a/scripts/stubtest/allowlist_todo.txt +++ b/scripts/stubtest/allowlist_todo.txt @@ -754,12 +754,6 @@ django.core.management.utils.run_formatters django.core.management.utils.sentinel django.core.servers.basehttp.ServerHandler.__init__ django.core.servers.basehttp.ThreadedWSGIServer.__init__ -django.core.signing.BASE62_ALPHABET -django.core.signing.Signer.__init__ -django.core.signing.Signer.signature -django.core.signing.b62_decode -django.core.signing.b62_encode -django.core.signing.loads django.db.backends.ddl_references.Expressions django.db.backends.mysql.base django.db.backends.mysql.features.DatabaseFeatures.can_rename_index