diff --git a/news/9831.bugfix.rst b/news/9831.bugfix.rst new file mode 100644 index 00000000000..cfdff53a140 --- /dev/null +++ b/news/9831.bugfix.rst @@ -0,0 +1 @@ +This change fixes a bug on Python <=3.6.1 with a Typing feature added in 3.6.2 diff --git a/src/pip/_internal/req/req_file.py b/src/pip/_internal/req/req_file.py index f6bdfd19b7d..080c128199d 100644 --- a/src/pip/_internal/req/req_file.py +++ b/src/pip/_internal/req/req_file.py @@ -8,17 +8,7 @@ import shlex import urllib.parse from optparse import Values -from typing import ( - TYPE_CHECKING, - Any, - Callable, - Dict, - Iterator, - List, - NoReturn, - Optional, - Tuple, -) +from typing import TYPE_CHECKING, Any, Callable, Dict, Iterator, List, Optional, Tuple from pip._internal.cli import cmdoptions from pip._internal.exceptions import InstallationError, RequirementsFileParseError @@ -29,6 +19,10 @@ from pip._internal.utils.urls import get_url_scheme, url_to_path if TYPE_CHECKING: + # NoReturn introduced in 3.6.2; imported only for type checking to maintain + # pip compatibility with older patch versions of Python 3.6 + from typing import NoReturn + from pip._internal.index.package_finder import PackageFinder __all__ = ['parse_requirements'] diff --git a/src/pip/_internal/utils/hashes.py b/src/pip/_internal/utils/hashes.py index e0ecf6ee902..3d20b8d02cd 100644 --- a/src/pip/_internal/utils/hashes.py +++ b/src/pip/_internal/utils/hashes.py @@ -1,5 +1,5 @@ import hashlib -from typing import TYPE_CHECKING, BinaryIO, Dict, Iterator, List, NoReturn +from typing import TYPE_CHECKING, BinaryIO, Dict, Iterator, List from pip._internal.exceptions import HashMismatch, HashMissing, InstallationError from pip._internal.utils.misc import read_chunks @@ -7,6 +7,10 @@ if TYPE_CHECKING: from hashlib import _Hash + # NoReturn introduced in 3.6.2; imported only for type checking to maintain + # pip compatibility with older patch versions of Python 3.6 + from typing import NoReturn + # The recommended hash algo of the moment. Change this whenever the state of # the art changes; it won't hurt backward compatibility.