Skip to content

Commit a1548fa

Browse files
committed
Fix string formatting style, add req source.
1 parent 50c5282 commit a1548fa

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/pip/_internal/req/constructors.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -239,24 +239,25 @@ def with_source(text):
239239

240240
link = req.link
241241

242+
def get_install_error(text):
243+
return InstallationError(with_source(text))
244+
242245
if link and link.scheme == 'file':
243246
p = link.path
244247
if not os.path.exists(p):
245-
raise InstallationError(
246-
with_source(
247-
"Requirement '{}' looks like a path, but the "
248-
'file/directory does not exist'.format(name)
249-
)
248+
raise get_install_error(
249+
"Requirement '{}' looks like a path, but the "
250+
'file/directory does not exist'.format(name)
250251
)
251252

252253
if os.path.isdir(p):
253254
if not is_installable_dir(p):
254-
raise InstallationError(
255+
raise get_install_error(
255256
"Directory %r is not installable. Neither 'setup.py' "
256-
"nor 'pyproject.toml' found." % name
257+
"nor 'pyproject.toml' found.".format(name)
257258
)
258259
elif not is_archive_file(p) and not link.is_wheel:
259-
raise InstallationError(
260+
raise get_install_error(
260261
"Invalid requirement: {!r}, files must be wheels or "
261262
'archives'.format(name) + deduce_helpful_msg(p)
262263
)

0 commit comments

Comments
 (0)