From 84a176d09403d897f2ec4ec9c0fba84eb14c55e2 Mon Sep 17 00:00:00 2001 From: Andrew Zhou <0az@afzhou.com> Date: Tue, 20 Oct 2020 15:24:53 -0500 Subject: [PATCH 1/5] Add xxhash stub --- third_party/2and3/xxhash.pyi | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 third_party/2and3/xxhash.pyi diff --git a/third_party/2and3/xxhash.pyi b/third_party/2and3/xxhash.pyi new file mode 100644 index 000000000000..1fe6a933bdd9 --- /dev/null +++ b/third_party/2and3/xxhash.pyi @@ -0,0 +1,29 @@ +from _typeshed import ReadableBuffer +from hashlib import _Hash + +VERSION: str +XXHASH_VERSION: str + +class _IntDigestHash(_Hash): + def intdigest(self) -> int: ... + +# python-xxhash v2.0.0 does not support the string or usedforsecurity kwargs +def xxh32(__string: ReadableBuffer = ...) -> _IntDigestHash: ... +def xxh64(__string: ReadableBuffer = ...) -> _IntDigestHash: ... +def xxh3_64(__string: ReadableBuffer = ...) -> _IntDigestHash: ... +def xxh3_128(__string: ReadableBuffer = ...) -> _IntDigestHash: ... +def xxh32_digest(input: ReadableBuffer = ...) -> bytes: ... +def xxh32_intdigest(input: ReadableBuffer = ...) -> bytes: ... +def xxh32_hexdigest(input: ReadableBuffer = ...) -> bytes: ... +def xxh64_digest(input: ReadableBuffer = ...) -> bytes: ... +def xxh64_intdigest(input: ReadableBuffer = ...) -> bytes: ... +def xxh64_hexdigest(input: ReadableBuffer = ...) -> bytes: ... +def xxh3_64_digest(input: ReadableBuffer = ...) -> bytes: ... +def xxh3_64_intdigest(input: ReadableBuffer = ...) -> bytes: ... +def xxh3_64_hexdigest(input: ReadableBuffer = ...) -> bytes: ... +def xxh3_128_digest(input: ReadableBuffer = ...) -> bytes: ... +def xxh3_128_intdigest(input: ReadableBuffer = ...) -> bytes: ... +def xxh3_128_hexdigest(input: ReadableBuffer = ...) -> bytes: ... +def xxh128_digest(input: ReadableBuffer = ...) -> bytes: ... +def xxh128_intdigest(input: ReadableBuffer = ...) -> bytes: ... +def xxh128_hexdigest(input: ReadableBuffer = ...) -> bytes: ... From ca014a86c598652c4e662aed783e696bc4d1df68 Mon Sep 17 00:00:00 2001 From: Andrew Zhou <0az@afzhou.com> Date: Sun, 1 Nov 2020 15:23:09 -0600 Subject: [PATCH 2/5] xxhash: Use aliases for xxh_128* --- third_party/2and3/xxhash.pyi | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/third_party/2and3/xxhash.pyi b/third_party/2and3/xxhash.pyi index 1fe6a933bdd9..bbfe7ba04de9 100644 --- a/third_party/2and3/xxhash.pyi +++ b/third_party/2and3/xxhash.pyi @@ -24,6 +24,8 @@ def xxh3_64_hexdigest(input: ReadableBuffer = ...) -> bytes: ... def xxh3_128_digest(input: ReadableBuffer = ...) -> bytes: ... def xxh3_128_intdigest(input: ReadableBuffer = ...) -> bytes: ... def xxh3_128_hexdigest(input: ReadableBuffer = ...) -> bytes: ... -def xxh128_digest(input: ReadableBuffer = ...) -> bytes: ... -def xxh128_intdigest(input: ReadableBuffer = ...) -> bytes: ... -def xxh128_hexdigest(input: ReadableBuffer = ...) -> bytes: ... + +xxh128 = xxh3_128 +xxh128_digest = xxh3_128_digest +xxh128_intdigest = xxh3_128_intdigest +xxh128_hexdigest = xxh3_128_hexdigest From ed751f6762783a6fbc629d630ccd0882fcb5b3f0 Mon Sep 17 00:00:00 2001 From: Andrew Zhou <0az@afzhou.com> Date: Sun, 1 Nov 2020 15:39:22 -0600 Subject: [PATCH 3/5] xxhash: Use classes --- third_party/2and3/xxhash.pyi | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/third_party/2and3/xxhash.pyi b/third_party/2and3/xxhash.pyi index bbfe7ba04de9..2a8252d9635c 100644 --- a/third_party/2and3/xxhash.pyi +++ b/third_party/2and3/xxhash.pyi @@ -5,13 +5,15 @@ VERSION: str XXHASH_VERSION: str class _IntDigestHash(_Hash): + def __init__(self, __string: ReadableBuffer = ...): ... def intdigest(self) -> int: ... # python-xxhash v2.0.0 does not support the string or usedforsecurity kwargs -def xxh32(__string: ReadableBuffer = ...) -> _IntDigestHash: ... -def xxh64(__string: ReadableBuffer = ...) -> _IntDigestHash: ... -def xxh3_64(__string: ReadableBuffer = ...) -> _IntDigestHash: ... -def xxh3_128(__string: ReadableBuffer = ...) -> _IntDigestHash: ... +class xxh32(_IntDigestHash): ... +class xxh64(_IntDigestHash): ... +class xxh3_64(_IntDigestHash): ... +class xxh3_128(_IntDigestHash): ... + def xxh32_digest(input: ReadableBuffer = ...) -> bytes: ... def xxh32_intdigest(input: ReadableBuffer = ...) -> bytes: ... def xxh32_hexdigest(input: ReadableBuffer = ...) -> bytes: ... From 94365161422eccac7f80397f0eaa859a6778f769 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Sat, 23 Jan 2021 18:23:27 +0100 Subject: [PATCH 4/5] Fix for Python 2 --- third_party/2and3/xxhash.pyi | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/third_party/2and3/xxhash.pyi b/third_party/2and3/xxhash.pyi index 2a8252d9635c..6ab32318acb1 100644 --- a/third_party/2and3/xxhash.pyi +++ b/third_party/2and3/xxhash.pyi @@ -1,5 +1,11 @@ +import sys + from _typeshed import ReadableBuffer -from hashlib import _Hash + +if sys.version_info < (3,): + from hashlib import _hash as _Hash +else: + from hashlib import _Hash VERSION: str XXHASH_VERSION: str From 300b05bb42baa463e3409155d9556c3ae8e44421 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Sat, 23 Jan 2021 18:29:45 +0100 Subject: [PATCH 5/5] Run isort --- third_party/2and3/xxhash.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/third_party/2and3/xxhash.pyi b/third_party/2and3/xxhash.pyi index 6ab32318acb1..dc31adb6e45a 100644 --- a/third_party/2and3/xxhash.pyi +++ b/third_party/2and3/xxhash.pyi @@ -1,5 +1,4 @@ import sys - from _typeshed import ReadableBuffer if sys.version_info < (3,):