Skip to content

Commit 7a77484

Browse files
authored
Merge pull request #9835 from jamescurtin/9831-bugfix
Fix import error introduced in 21.1
2 parents 914bcc3 + 6d63690 commit 7a77484

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

news/9831.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This change fixes a bug on Python <=3.6.1 with a Typing feature added in 3.6.2

src/pip/_internal/req/req_file.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,7 @@
88
import shlex
99
import urllib.parse
1010
from optparse import Values
11-
from typing import (
12-
TYPE_CHECKING,
13-
Any,
14-
Callable,
15-
Dict,
16-
Iterator,
17-
List,
18-
NoReturn,
19-
Optional,
20-
Tuple,
21-
)
11+
from typing import TYPE_CHECKING, Any, Callable, Dict, Iterator, List, Optional, Tuple
2212

2313
from pip._internal.cli import cmdoptions
2414
from pip._internal.exceptions import InstallationError, RequirementsFileParseError
@@ -29,6 +19,10 @@
2919
from pip._internal.utils.urls import get_url_scheme, url_to_path
3020

3121
if TYPE_CHECKING:
22+
# NoReturn introduced in 3.6.2; imported only for type checking to maintain
23+
# pip compatibility with older patch versions of Python 3.6
24+
from typing import NoReturn
25+
3226
from pip._internal.index.package_finder import PackageFinder
3327

3428
__all__ = ['parse_requirements']

src/pip/_internal/utils/hashes.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import hashlib
2-
from typing import TYPE_CHECKING, BinaryIO, Dict, Iterator, List, NoReturn
2+
from typing import TYPE_CHECKING, BinaryIO, Dict, Iterator, List
33

44
from pip._internal.exceptions import HashMismatch, HashMissing, InstallationError
55
from pip._internal.utils.misc import read_chunks
66

77
if TYPE_CHECKING:
88
from hashlib import _Hash
99

10+
# NoReturn introduced in 3.6.2; imported only for type checking to maintain
11+
# pip compatibility with older patch versions of Python 3.6
12+
from typing import NoReturn
13+
1014

1115
# The recommended hash algo of the moment. Change this whenever the state of
1216
# the art changes; it won't hurt backward compatibility.

0 commit comments

Comments
 (0)