mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-08-30 19:46:57 +08:00
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:
+15
-2
@@ -2,13 +2,26 @@ import sys
|
||||
from _typeshed import ReadableBuffer
|
||||
from collections.abc import Callable
|
||||
from types import ModuleType
|
||||
from typing import AnyStr, final, overload
|
||||
from typing import AnyStr, Protocol, final, overload, type_check_only
|
||||
from typing_extensions import Self, TypeAlias
|
||||
|
||||
_DigestMod: TypeAlias = str | Callable[[], HASH] | ModuleType | None
|
||||
_DigestMod: TypeAlias = str | Callable[[], _HashObject] | ModuleType | None
|
||||
|
||||
openssl_md_meth_names: frozenset[str]
|
||||
|
||||
@type_check_only
|
||||
class _HashObject(Protocol):
|
||||
@property
|
||||
def digest_size(self) -> int: ...
|
||||
@property
|
||||
def block_size(self) -> int: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
def copy(self) -> Self: ...
|
||||
def digest(self) -> bytes: ...
|
||||
def hexdigest(self) -> str: ...
|
||||
def update(self, obj: ReadableBuffer, /) -> None: ...
|
||||
|
||||
class HASH:
|
||||
@property
|
||||
def digest_size(self) -> int: ...
|
||||
|
||||
Reference in New Issue
Block a user