Skip to content

Commit

Permalink
Merge pull request #9835 from jamescurtin/9831-bugfix
Browse files Browse the repository at this point in the history
Fix import error introduced in 21.1
  • Loading branch information
sbidoul committed Apr 25, 2021
2 parents 914bcc3 + 6d63690 commit 7a77484
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
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

0 comments on commit 7a77484

Please sign in to comment.