From 0a69743bca5d3296ad9b0653cba8c88e2733b939 Mon Sep 17 00:00:00 2001 From: Shantanu Date: Sat, 16 May 2020 16:31:12 -0700 Subject: [PATCH] hashlib: fix argument kinds, update for py39 (#4006) * hashlib: add usedforsecurity in py39 * hashlib: fix positional-only args, arg names * hashlib: fix positional and keyword only args for blake * hashlib: add usedforsecurity to blake --- stdlib/3/hashlib.pyi | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/stdlib/3/hashlib.pyi b/stdlib/3/hashlib.pyi index a0bc13cc7..66e181791 100644 --- a/stdlib/3/hashlib.pyi +++ b/stdlib/3/hashlib.pyi @@ -19,9 +19,16 @@ class _Hash(object): def copy(self) -> _Hash: ... def digest(self) -> bytes: ... def hexdigest(self) -> str: ... - def update(self, arg: _DataType) -> None: ... + def update(self, __data: _DataType) -> None: ... -if sys.version_info >= (3, 8): +if sys.version_info >= (3, 9): + def md5(string: _DataType = ..., *, usedforsecurity: bool = ...) -> _Hash: ... + def sha1(string: _DataType = ..., *, usedforsecurity: bool = ...) -> _Hash: ... + def sha224(string: _DataType = ..., *, usedforsecurity: bool = ...) -> _Hash: ... + def sha256(string: _DataType = ..., *, usedforsecurity: bool = ...) -> _Hash: ... + def sha384(string: _DataType = ..., *, usedforsecurity: bool = ...) -> _Hash: ... + def sha512(string: _DataType = ..., *, usedforsecurity: bool = ...) -> _Hash: ... +elif sys.version_info >= (3, 8): def md5(string: _DataType = ...) -> _Hash: ... def sha1(string: _DataType = ...) -> _Hash: ... def sha224(string: _DataType = ...) -> _Hash: ... @@ -52,9 +59,9 @@ if sys.version_info >= (3, 6): def __init__(self, data: _DataType = ...) -> None: ... def copy(self) -> _VarLenHash: ... - def digest(self, length: int) -> bytes: ... - def hexdigest(self, length: int) -> str: ... - def update(self, arg: _DataType) -> None: ... + def digest(self, __length: int) -> bytes: ... + def hexdigest(self, __length: int) -> str: ... + def update(self, __data: _DataType) -> None: ... sha3_224 = _Hash sha3_256 = _Hash @@ -71,7 +78,10 @@ if sys.version_info >= (3, 6): PERSON_SIZE: int SALT_SIZE: int - def __init__(self, data: _DataType = ..., digest_size: int = ..., key: _DataType = ..., salt: _DataType = ..., person: _DataType = ..., fanout: int = ..., depth: int = ..., leaf_size: int = ..., node_offset: int = ..., node_depth: int = ..., inner_size: int = ..., last_node: bool = ...) -> None: ... + if sys.version_info >= (3, 9): + def __init__(self, __data: _DataType = ..., *, digest_size: int = ..., key: _DataType = ..., salt: _DataType = ..., person: _DataType = ..., fanout: int = ..., depth: int = ..., leaf_size: int = ..., node_offset: int = ..., node_depth: int = ..., inner_size: int = ..., last_node: bool = ..., usedforsecurity: bool = ...) -> None: ... + else: + def __init__(self, __data: _DataType = ..., *, digest_size: int = ..., key: _DataType = ..., salt: _DataType = ..., person: _DataType = ..., fanout: int = ..., depth: int = ..., leaf_size: int = ..., node_offset: int = ..., node_depth: int = ..., inner_size: int = ..., last_node: bool = ...) -> None: ... blake2b = _BlakeHash blake2s = _BlakeHash