Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix import error introduced in 21.1 #9835

Merged
merged 1 commit into from
Apr 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/9831.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This change fixes a bug on Python <=3.6.1 with a Typing feature added in 3.6.2
16 changes: 5 additions & 11 deletions src/pip/_internal/req/req_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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']
Expand Down
6 changes: 5 additions & 1 deletion src/pip/_internal/utils/hashes.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
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

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.
Expand Down