4
4
5
5
from astroid .brain .helpers import register_module_extender
6
6
from astroid .builder import parse
7
+ from astroid .const import PY39_PLUS
7
8
from astroid .manager import AstroidManager
8
9
9
10
10
11
def _hashlib_transform ():
11
- signature = "value='', usedforsecurity=True"
12
+ maybe_usedforsecurity = ", usedforsecurity=True" if PY39_PLUS else ""
13
+ signature = f"value=''{ maybe_usedforsecurity } "
12
14
template = """
13
15
class %(name)s(object):
14
16
def __init__(self, %(signature)s): pass
@@ -32,12 +34,12 @@ def digest_size(self):
32
34
algorithms_with_signature = dict .fromkeys (
33
35
["md5" , "sha1" , "sha224" , "sha256" , "sha384" , "sha512" ], signature
34
36
)
35
- blake2b_signature = "data=b'', *, digest_size=64, key=b'', salt=b'', \
37
+ blake2b_signature = f "data=b'', *, digest_size=64, key=b'', salt=b'', \
36
38
person=b'', fanout=1, depth=1, leaf_size=0, node_offset=0, \
37
- node_depth=0, inner_size=0, last_node=False, usedforsecurity=True "
38
- blake2s_signature = "data=b'', *, digest_size=32, key=b'', salt=b'', \
39
+ node_depth=0, inner_size=0, last_node=False{ maybe_usedforsecurity } "
40
+ blake2s_signature = f "data=b'', *, digest_size=32, key=b'', salt=b'', \
39
41
person=b'', fanout=1, depth=1, leaf_size=0, node_offset=0, \
40
- node_depth=0, inner_size=0, last_node=False, usedforsecurity=True "
42
+ node_depth=0, inner_size=0, last_node=False{ maybe_usedforsecurity } "
41
43
new_algorithms = dict .fromkeys (
42
44
["sha3_224" , "sha3_256" , "sha3_384" , "sha3_512" , "shake_128" , "shake_256" ],
43
45
signature ,
0 commit comments