mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-02-17 07:14:12 +08:00
Update the xxhash and hashlib stubs (#6031)
* `name`, `block_size`, `digest_size` and `digestsize` attributes of hash objects were made read-only. * It is now a type-checking error to subclass `xxhash` classes, such as `xxhash.xxh32`. Previously it was an error only at runtime. * `xxhash` functions now accept strings as input and any object with `__index__()` method for `seed` (instead of requiring an integer). They also fail the type checking if no arguments are given.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user