Introduce the _HashObject protocol (#13553)

This protocol corresponds to what is called "hash object" in the hashlib documentation. In particular, it includes the non-OpenSSL BLAKE2 implementations which do not inherit HASH.
This commit is contained in:
Pierre Chapuis
2025-02-27 15:31:56 +01:00
committed by GitHub
parent 14605d0c21
commit b0c6fffe28
3 changed files with 19 additions and 5 deletions
+2 -1
View File
@@ -2,6 +2,7 @@ import sys
from _blake2 import blake2b as blake2b, blake2s as blake2s
from _hashlib import (
HASH,
_HashObject,
openssl_md5 as md5,
openssl_sha1 as sha1,
openssl_sha224 as sha224,
@@ -97,7 +98,7 @@ if sys.version_info >= (3, 11):
def readable(self) -> bool: ...
def file_digest(
fileobj: _BytesIOLike | _FileDigestFileObj, digest: str | Callable[[], HASH], /, *, _bufsize: int = 262144
fileobj: _BytesIOLike | _FileDigestFileObj, digest: str | Callable[[], _HashObject], /, *, _bufsize: int = 262144
) -> HASH: ...
# Legacy typing-only alias