|
13 | 13 |
|
14 | 14 | from . import __version__
|
15 | 15 |
|
16 |
| -# Between different versions of pip the location of PipSession has changed. |
17 |
| -try: |
18 |
| - from pip._internal.network.session import PipSession |
19 |
| -except ImportError: # pragma: no cover |
20 |
| - from pip._internal.download import PipSession |
| 16 | +from pip._internal.network.session import PipSession |
| 17 | +from pip._internal.req.constructors import install_req_from_line |
21 | 18 | from pip._internal.req.req_file import parse_requirements
|
22 | 19 |
|
23 | 20 |
|
@@ -137,16 +134,9 @@ def find_required_modules(options, requirements_filename: str):
|
137 | 134 | explicit = set()
|
138 | 135 | for requirement in parse_requirements(requirements_filename,
|
139 | 136 | session=PipSession()):
|
140 |
| - try: |
141 |
| - requirement_name = requirement.name |
142 |
| - # The type of "requirement" changed between pip versions. |
143 |
| - # We exclude the "except" from coverage so that on any pip version we |
144 |
| - # can report 100% coverage. |
145 |
| - except AttributeError: # pragma: no cover |
146 |
| - from pip._internal.req.constructors import install_req_from_line |
147 |
| - requirement_name = install_req_from_line( |
148 |
| - requirement.requirement, |
149 |
| - ).name |
| 137 | + requirement_name = install_req_from_line( |
| 138 | + requirement.requirement, |
| 139 | + ).name |
150 | 140 |
|
151 | 141 | if options.ignore_reqs(requirement):
|
152 | 142 | log.debug('ignoring requirement: %s', requirement_name)
|
@@ -193,13 +183,10 @@ def ignorer(ignore_cfg):
|
193 | 183 | def f(candidate, ignore_cfg=ignore_cfg):
|
194 | 184 | for ignore in ignore_cfg:
|
195 | 185 | try:
|
196 |
| - from pip._internal.req.constructors import ( |
197 |
| - install_req_from_line, |
198 |
| - ) |
199 |
| - candidate_path = install_req_from_line( # pragma: no cover |
| 186 | + candidate_path = install_req_from_line( |
200 | 187 | candidate.requirement,
|
201 | 188 | ).name
|
202 |
| - except (ImportError, AttributeError): |
| 189 | + except AttributeError: |
203 | 190 | try:
|
204 | 191 | candidate_path = candidate.name
|
205 | 192 | except AttributeError:
|
|
0 commit comments