diff --git a/stdlib/2and3/hmac.pyi b/stdlib/2and3/hmac.pyi index 47bbc7ec0..fd550e320 100644 --- a/stdlib/2and3/hmac.pyi +++ b/stdlib/2and3/hmac.pyi @@ -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: diff --git a/tests/stubtest_whitelists/py38.txt b/tests/stubtest_whitelists/py38.txt index bbdb0a3ac..8f9fef8e2 100644 --- a/tests/stubtest_whitelists/py38.txt +++ b/tests/stubtest_whitelists/py38.txt @@ -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__ diff --git a/tests/stubtest_whitelists/py39.txt b/tests/stubtest_whitelists/py39.txt index fd2feb868..41ad9ada2 100644 --- a/tests/stubtest_whitelists/py39.txt +++ b/tests/stubtest_whitelists/py39.txt @@ -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__