diff --git a/stdlib/@python2/hashlib.pyi b/stdlib/@python2/hashlib.pyi index 842804b4c..9c53d2b6b 100644 --- a/stdlib/@python2/hashlib.pyi +++ b/stdlib/@python2/hashlib.pyi @@ -3,10 +3,14 @@ from typing import Tuple, Union _DataType = Union[str, unicode, bytearray, buffer, memoryview] class _hash(object): # This is not actually in the module namespace. - name: str - block_size: int - digest_size: int - digestsize: int + @property + def name(self) -> str: ... + @property + def block_size(self) -> int: ... + @property + def digest_size(self) -> int: ... + @property + def digestsize(self) -> int: ... def __init__(self, arg: _DataType = ...) -> None: ... def update(self, arg: _DataType) -> None: ... def digest(self) -> str: ... diff --git a/stdlib/hashlib.pyi b/stdlib/hashlib.pyi index 3f86ed73a..e39f2f253 100644 --- a/stdlib/hashlib.pyi +++ b/stdlib/hashlib.pyi @@ -1,17 +1,16 @@ import sys -from _typeshed import ReadableBuffer +from _typeshed import ReadableBuffer, Self from typing import AbstractSet class _Hash(object): - digest_size: int - block_size: int - - # [Python documentation note] Changed in version 3.4: The name attribute has - # been present in CPython since its inception, but until Python 3.4 was not - # formally specified, so may not exist on some platforms - name: str + @property + def digest_size(self) -> int: ... + @property + def block_size(self) -> int: ... + @property + def name(self) -> str: ... def __init__(self, data: ReadableBuffer = ...) -> None: ... - def copy(self) -> _Hash: ... + def copy(self: Self) -> Self: ... def digest(self) -> bytes: ... def hexdigest(self) -> str: ... def update(self, __data: ReadableBuffer) -> None: ... diff --git a/stubs/xxhash/xxhash.pyi b/stubs/xxhash/xxhash.pyi index bca6a321b..0e0b7cff5 100644 --- a/stubs/xxhash/xxhash.pyi +++ b/stubs/xxhash/xxhash.pyi @@ -1,5 +1,6 @@ import sys from _typeshed import ReadableBuffer +from typing_extensions import SupportsIndex, final if sys.version_info >= (3, 0): from hashlib import _Hash @@ -10,30 +11,39 @@ VERSION: str XXHASH_VERSION: str class _IntDigestHash(_Hash): - seed: int - digestsize: int - def __init__(self, __string: ReadableBuffer = ..., seed: int = ...) -> None: ... + @property + def seed(self) -> int: ... + @property + def digestsize(self) -> int: ... + def __init__(self, input: ReadableBuffer | str = ..., seed: SupportsIndex = ...) -> None: ... def intdigest(self) -> int: ... def reset(self) -> None: ... # python-xxhash v2.0.0 does not support the string or usedforsecurity kwargs +@final class xxh32(_IntDigestHash): ... + +@final class xxh64(_IntDigestHash): ... + +@final class xxh3_64(_IntDigestHash): ... + +@final class xxh3_128(_IntDigestHash): ... -def xxh32_digest(input: ReadableBuffer = ..., seed: int = ...) -> bytes: ... -def xxh32_intdigest(input: ReadableBuffer = ..., seed: int = ...) -> int: ... -def xxh32_hexdigest(input: ReadableBuffer = ..., seed: int = ...) -> str: ... -def xxh64_digest(input: ReadableBuffer = ..., seed: int = ...) -> bytes: ... -def xxh64_intdigest(input: ReadableBuffer = ..., seed: int = ...) -> int: ... -def xxh64_hexdigest(input: ReadableBuffer = ..., seed: int = ...) -> str: ... -def xxh3_64_digest(input: ReadableBuffer = ..., seed: int = ...) -> bytes: ... -def xxh3_64_intdigest(input: ReadableBuffer = ..., seed: int = ...) -> int: ... -def xxh3_64_hexdigest(input: ReadableBuffer = ..., seed: int = ...) -> str: ... -def xxh3_128_digest(input: ReadableBuffer = ..., seed: int = ...) -> bytes: ... -def xxh3_128_intdigest(input: ReadableBuffer = ..., seed: int = ...) -> int: ... -def xxh3_128_hexdigest(input: ReadableBuffer = ..., seed: int = ...) -> str: ... +def xxh32_digest(input: ReadableBuffer | str, seed: SupportsIndex = ...) -> bytes: ... +def xxh32_intdigest(input: ReadableBuffer | str, seed: SupportsIndex = ...) -> int: ... +def xxh32_hexdigest(input: ReadableBuffer | str, seed: SupportsIndex = ...) -> str: ... +def xxh64_digest(input: ReadableBuffer | str, seed: SupportsIndex = ...) -> bytes: ... +def xxh64_intdigest(input: ReadableBuffer | str, seed: SupportsIndex = ...) -> int: ... +def xxh64_hexdigest(input: ReadableBuffer | str, seed: SupportsIndex = ...) -> str: ... +def xxh3_64_digest(input: ReadableBuffer | str, seed: SupportsIndex = ...) -> bytes: ... +def xxh3_64_intdigest(input: ReadableBuffer | str, seed: SupportsIndex = ...) -> int: ... +def xxh3_64_hexdigest(input: ReadableBuffer | str, seed: SupportsIndex = ...) -> str: ... +def xxh3_128_digest(input: ReadableBuffer | str, seed: SupportsIndex = ...) -> bytes: ... +def xxh3_128_intdigest(input: ReadableBuffer | str, seed: SupportsIndex = ...) -> int: ... +def xxh3_128_hexdigest(input: ReadableBuffer | str, seed: SupportsIndex = ...) -> str: ... xxh128 = xxh3_128 xxh128_digest = xxh3_128_digest