From 9d07d74a12fff10d728b860335c542afbd04fbcf Mon Sep 17 00:00:00 2001 From: Nick M <50747025+mcdonnnj@users.noreply.github.com> Date: Tue, 26 Jan 2021 11:01:55 -0500 Subject: [PATCH] Update type hints for the hashlib.new() stub (#4973) Python 3.9 added the usedforsecurity kwarg as discussed in: https://bugs.python.org/issue9216 The stubs for the other constructors were updated to reflect this change, but the stub for new() was missed. --- stdlib/3/hashlib.pyi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stdlib/3/hashlib.pyi b/stdlib/3/hashlib.pyi index 70b120d08..e4aee2145 100644 --- a/stdlib/3/hashlib.pyi +++ b/stdlib/3/hashlib.pyi @@ -17,6 +17,7 @@ class _Hash(object): def update(self, __data: ReadableBuffer) -> None: ... if sys.version_info >= (3, 9): + def new(name: str, data: ReadableBuffer = ..., *, usedforsecurity: bool = ...) -> _Hash: ... def md5(string: ReadableBuffer = ..., *, usedforsecurity: bool = ...) -> _Hash: ... def sha1(string: ReadableBuffer = ..., *, usedforsecurity: bool = ...) -> _Hash: ... def sha224(string: ReadableBuffer = ..., *, usedforsecurity: bool = ...) -> _Hash: ... @@ -25,6 +26,7 @@ if sys.version_info >= (3, 9): def sha512(string: ReadableBuffer = ..., *, usedforsecurity: bool = ...) -> _Hash: ... elif sys.version_info >= (3, 8): + def new(name: str, data: ReadableBuffer = ...) -> _Hash: ... def md5(string: ReadableBuffer = ...) -> _Hash: ... def sha1(string: ReadableBuffer = ...) -> _Hash: ... def sha224(string: ReadableBuffer = ...) -> _Hash: ... @@ -33,6 +35,7 @@ elif sys.version_info >= (3, 8): def sha512(string: ReadableBuffer = ...) -> _Hash: ... else: + def new(name: str, data: ReadableBuffer = ...) -> _Hash: ... def md5(__string: ReadableBuffer = ...) -> _Hash: ... def sha1(__string: ReadableBuffer = ...) -> _Hash: ... def sha224(__string: ReadableBuffer = ...) -> _Hash: ... @@ -40,8 +43,6 @@ else: def sha384(__string: ReadableBuffer = ...) -> _Hash: ... def sha512(__string: ReadableBuffer = ...) -> _Hash: ... -def new(name: str, data: ReadableBuffer = ...) -> _Hash: ... - algorithms_guaranteed: AbstractSet[str] algorithms_available: AbstractSet[str]