Skip to content

Commit 67425a8

Browse files
hauntsaninjaAkuli
andauthored
hashlib: update for py311 (#7652)
Co-authored-by: Akuli <akuviljanen17@gmail.com>
1 parent 617d2aa commit 67425a8

File tree

1 file changed

+57
-21
lines changed

1 file changed

+57
-21
lines changed

stdlib/hashlib.pyi

Lines changed: 57 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,52 @@
11
import sys
22
from _typeshed import ReadableBuffer, Self
3-
from collections.abc import Set as AbstractSet
3+
from collections.abc import Callable, Set as AbstractSet
4+
from typing import Protocol
45
from typing_extensions import final
56

6-
__all__ = (
7-
"md5",
8-
"sha1",
9-
"sha224",
10-
"sha256",
11-
"sha384",
12-
"sha512",
13-
"blake2b",
14-
"blake2s",
15-
"sha3_224",
16-
"sha3_256",
17-
"sha3_384",
18-
"sha3_512",
19-
"shake_128",
20-
"shake_256",
21-
"new",
22-
"algorithms_guaranteed",
23-
"algorithms_available",
24-
"pbkdf2_hmac",
25-
)
7+
if sys.version_info >= (3, 11):
8+
__all__ = (
9+
"md5",
10+
"sha1",
11+
"sha224",
12+
"sha256",
13+
"sha384",
14+
"sha512",
15+
"blake2b",
16+
"blake2s",
17+
"sha3_224",
18+
"sha3_256",
19+
"sha3_384",
20+
"sha3_512",
21+
"shake_128",
22+
"shake_256",
23+
"new",
24+
"algorithms_guaranteed",
25+
"algorithms_available",
26+
"pbkdf2_hmac",
27+
"file_digest",
28+
)
29+
else:
30+
__all__ = (
31+
"md5",
32+
"sha1",
33+
"sha224",
34+
"sha256",
35+
"sha384",
36+
"sha512",
37+
"blake2b",
38+
"blake2s",
39+
"sha3_224",
40+
"sha3_256",
41+
"sha3_384",
42+
"sha3_512",
43+
"shake_128",
44+
"shake_256",
45+
"new",
46+
"algorithms_guaranteed",
47+
"algorithms_available",
48+
"pbkdf2_hmac",
49+
)
2650

2751
class _Hash:
2852
@property
@@ -143,3 +167,15 @@ class _BlakeHash(_Hash):
143167

144168
blake2b = _BlakeHash
145169
blake2s = _BlakeHash
170+
171+
if sys.version_info >= (3, 11):
172+
class _BytesIOLike(Protocol):
173+
def getbuffer(self) -> ReadableBuffer: ...
174+
175+
class _FileDigestFileObj(Protocol):
176+
def readinto(self, __buf: bytearray) -> int: ...
177+
def readable(self) -> bool: ...
178+
179+
def file_digest(
180+
__fileobj: _BytesIOLike | _FileDigestFileObj, __digest: str | Callable[[], _Hash], *, _bufsize: int = ...
181+
) -> _Hash: ...

0 commit comments

Comments
 (0)