hmac digestmod is no longer Optional as of 3.8. (#3367)

This commit is contained in:
Gregory P. Smith
2020-05-28 00:24:32 -07:00
committed by GitHub
parent 2f0e3dbed2
commit a9d5a1ed99
3 changed files with 12 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
# Stubs for hmac
from typing import Any, Callable, Optional, Union, overload, AnyStr
from typing import Any, Callable, Optional, Union, overload, AnyStr, overload
from types import ModuleType
import sys
@@ -11,7 +11,15 @@ _Hash = Any
digest_size: None
if sys.version_info >= (3, 4):
if sys.version_info >= (3, 8):
_DigestMod = Union[str, Callable[[], _Hash], ModuleType]
# In reality digestmod has a default value, but the function always throws an error
# if the argument is not given, so we pretend it is a required argument.
@overload
def new(key: _B, msg: Optional[_B], digestmod: _DigestMod) -> HMAC: ...
@overload
def new(key: _B, *, digestmod: _DigestMod) -> HMAC: ...
elif sys.version_info >= (3, 4):
def new(key: _B, msg: Optional[_B] = ...,
digestmod: Optional[Union[str, Callable[[], _Hash], ModuleType]] = ...) -> HMAC: ...
else:

View File

@@ -46,6 +46,7 @@ functools.partialmethod.__get__
functools.singledispatchmethod.__call__ # A lie to reflect that the descriptor get returns a callable
gettext.install
gettext.translation
hmac.new # Stub is a white lie; see comments in the stub
http.client.HTTPSConnection.__init__
http.cookiejar.DefaultCookiePolicy.__init__
http.server.SimpleHTTPRequestHandler.__init__

View File

@@ -97,6 +97,7 @@ functools.singledispatchmethod.__call__
gettext.install
gettext.translation
hmac.compare_digest
hmac.new # Stub is a white lie; see comments in the stub
http.client.HTTPSConnection.__init__
http.cookiejar.DefaultCookiePolicy.__init__
http.server.SimpleHTTPRequestHandler.__init__