diff --git a/docs/pip_sphinxext.py b/docs/pip_sphinxext.py
index bfc5a6b4a..a0e69c6e4 100644
--- a/docs/pip_sphinxext.py
+++ b/docs/pip_sphinxext.py
@@ -55,7 +55,7 @@ class PipOptions(rst.Directive):
line += option._long_opts[0]
if option.takes_value():
metavar = option.metavar or option.dest.lower()
- line += " <%s>" % metavar.lower()
+ line += " <{}>".format(metavar.lower())
# fix defaults
opt_help = option.help.replace('%default', str(option.default))
# fix paths with sys.prefix
diff --git a/news/37d2f118-19f0-4c2c-b002-d70a8629b350.trivial b/news/37d2f118-19f0-4c2c-b002-d70a8629b350.trivial
new file mode 100644
index 000000000..e69de29bb
diff --git a/src/pip/_internal/exceptions.py b/src/pip/_internal/exceptions.py
index 882529dec..115f7eb0c 100644
--- a/src/pip/_internal/exceptions.py
+++ b/src/pip/_internal/exceptions.py
@@ -150,10 +150,10 @@ class HashError(InstallationError):
populate_link() having already been called
"""
- return ' %s' % self._requirement_name()
+ return ' {}'.format(self._requirement_name())
def __str__(self):
- return '%s\n%s' % (self.head, self.body())
+ return '{}\n{}'.format(self.head, self.body())
def _requirement_name(self):
"""Return a description of the requirement that triggered me.
@@ -215,9 +215,9 @@ class HashMissing(HashError):
# In case someone feeds something downright stupid
# to InstallRequirement's constructor.
else getattr(self.req, 'req', None))
- return ' %s --hash=%s:%s' % (package or 'unknown package',
- FAVORITE_HASH,
- self.gotten_hash)
+ return ' {} --hash={}:{}'.format(package or 'unknown package',
+ FAVORITE_HASH,
+ self.gotten_hash)
class HashUnpinned(HashError):
diff --git a/src/pip/_internal/models/link.py b/src/pip/_internal/models/link.py
index 1b3aa591a..0b30ab251 100644
--- a/src/pip/_internal/models/link.py
+++ b/src/pip/_internal/models/link.py
@@ -77,7 +77,7 @@ class Link(KeyBasedCompareMixin):
def __repr__(self):
# type: () -> str
- return '' % self
+ return ''.format(self)
@property
def url(self):
diff --git a/src/pip/_internal/req/constructors.py b/src/pip/_internal/req/constructors.py
index c350aaa8d..ddceabfd7 100644
--- a/src/pip/_internal/req/constructors.py
+++ b/src/pip/_internal/req/constructors.py
@@ -123,8 +123,8 @@ def parse_editable(editable_req):
return package_name, url_no_extras, None
for version_control in vcs:
- if url.lower().startswith('%s:' % version_control):
- url = '%s+%s' % (version_control, url)
+ if url.lower().startswith('{}:'.format(version_control)):
+ url = '{}+{}'.format(version_control, url)
break
if '+' not in url:
@@ -175,8 +175,8 @@ def deduce_helpful_msg(req):
" the packages specified within it."
).format(req)
except RequirementParseError:
- logger.debug("Cannot parse '%s' as requirements \
- file" % (req), exc_info=True)
+ logger.debug("Cannot parse '{}' as requirements \
+ file".format(req), exc_info=True)
else:
msg += " File '{}' does not exist.".format(req)
return msg
diff --git a/tests/unit/test_req.py b/tests/unit/test_req.py
index 29a239262..8ef40833a 100644
--- a/tests/unit/test_req.py
+++ b/tests/unit/test_req.py
@@ -449,14 +449,14 @@ class TestInstallRequirement(object):
def test_markers_url(self):
# test "URL; markers" syntax
url = 'http://foo.com/?p=bar.git;a=snapshot;h=v0.1;sf=tgz'
- line = '%s; python_version >= "3"' % url
+ line = '{}; python_version >= "3"'.format(url)
req = install_req_from_line(line)
assert req.link.url == url, req.url
assert str(req.markers) == 'python_version >= "3"'
# without space, markers are part of the URL
url = 'http://foo.com/?p=bar.git;a=snapshot;h=v0.1;sf=tgz'
- line = '%s;python_version >= "3"' % url
+ line = '{};python_version >= "3"'.format(url)
req = install_req_from_line(line)
assert req.link.url == line, req.url
assert req.markers is None
@@ -506,7 +506,7 @@ class TestInstallRequirement(object):
def test_extras_for_line_path_requirement(self):
line = 'SomeProject[ex1,ex2]'
filename = 'filename'
- comes_from = '-r %s (line %s)' % (filename, 1)
+ comes_from = '-r {} (line {})'.format(filename, 1)
req = install_req_from_line(line, comes_from=comes_from)
assert len(req.extras) == 2
assert req.extras == {'ex1', 'ex2'}
@@ -514,7 +514,7 @@ class TestInstallRequirement(object):
def test_extras_for_line_url_requirement(self):
line = 'git+https://url#egg=SomeProject[ex1,ex2]'
filename = 'filename'
- comes_from = '-r %s (line %s)' % (filename, 1)
+ comes_from = '-r {} (line {})'.format(filename, 1)
req = install_req_from_line(line, comes_from=comes_from)
assert len(req.extras) == 2
assert req.extras == {'ex1', 'ex2'}
@@ -522,7 +522,7 @@ class TestInstallRequirement(object):
def test_extras_for_editable_path_requirement(self):
url = '.[ex1,ex2]'
filename = 'filename'
- comes_from = '-r %s (line %s)' % (filename, 1)
+ comes_from = '-r {} (line {})'.format(filename, 1)
req = install_req_from_editable(url, comes_from=comes_from)
assert len(req.extras) == 2
assert req.extras == {'ex1', 'ex2'}
@@ -530,7 +530,7 @@ class TestInstallRequirement(object):
def test_extras_for_editable_url_requirement(self):
url = 'git+https://url#egg=SomeProject[ex1,ex2]'
filename = 'filename'
- comes_from = '-r %s (line %s)' % (filename, 1)
+ comes_from = '-r {} (line {})'.format(filename, 1)
req = install_req_from_editable(url, comes_from=comes_from)
assert len(req.extras) == 2
assert req.extras == {'ex1', 'ex2'}
diff --git a/tests/unit/test_req_file.py b/tests/unit/test_req_file.py
index 597fc2f82..846aeaeff 100644
--- a/tests/unit/test_req_file.py
+++ b/tests/unit/test_req_file.py
@@ -249,21 +249,21 @@ class TestProcessLine(object):
def test_yield_line_requirement(self, line_processor):
line = 'SomeProject'
filename = 'filename'
- comes_from = '-r %s (line %s)' % (filename, 1)
+ comes_from = '-r {} (line {})'.format(filename, 1)
req = install_req_from_line(line, comes_from=comes_from)
assert repr(line_processor(line, filename, 1)[0]) == repr(req)
def test_yield_pep440_line_requirement(self, line_processor):
line = 'SomeProject @ https://url/SomeProject-py2-py3-none-any.whl'
filename = 'filename'
- comes_from = '-r %s (line %s)' % (filename, 1)
+ comes_from = '-r {} (line {})'.format(filename, 1)
req = install_req_from_line(line, comes_from=comes_from)
assert repr(line_processor(line, filename, 1)[0]) == repr(req)
def test_yield_line_constraint(self, line_processor):
line = 'SomeProject'
filename = 'filename'
- comes_from = '-c %s (line %s)' % (filename, 1)
+ comes_from = '-c {} (line {})'.format(filename, 1)
req = install_req_from_line(
line, comes_from=comes_from, constraint=True)
found_req = line_processor(line, filename, 1, constraint=True)[0]
@@ -275,7 +275,7 @@ class TestProcessLine(object):
):
line = 'SomeProject >= 2'
filename = 'filename'
- comes_from = '-r %s (line %s)' % (filename, 1)
+ comes_from = '-r {} (line {})'.format(filename, 1)
req = install_req_from_line(line, comes_from=comes_from)
assert repr(line_processor(line, filename, 1)[0]) == repr(req)
assert str(req.req.specifier) == '>=2'
@@ -284,15 +284,15 @@ class TestProcessLine(object):
url = 'git+https://url#egg=SomeProject'
line = '-e %s' % url
filename = 'filename'
- comes_from = '-r %s (line %s)' % (filename, 1)
+ comes_from = '-r {} (line {})'.format(filename, 1)
req = install_req_from_editable(url, comes_from=comes_from)
assert repr(line_processor(line, filename, 1)[0]) == repr(req)
def test_yield_editable_constraint(self, line_processor):
url = 'git+https://url#egg=SomeProject'
- line = '-e %s' % url
+ line = '-e {}'.format(url)
filename = 'filename'
- comes_from = '-c %s (line %s)' % (filename, 1)
+ comes_from = '-c {} (line {})'.format(filename, 1)
req = install_req_from_editable(
url, comes_from=comes_from, constraint=True)
found_req = line_processor(line, filename, 1, constraint=True)[0]
diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py
index 011543bdc..fa042519e 100644
--- a/tests/unit/test_utils.py
+++ b/tests/unit/test_utils.py
@@ -66,11 +66,11 @@ class Tests_EgglinkPath:
self.user_site = 'USER_SITE'
self.user_site_egglink = os.path.join(
self.user_site,
- '%s.egg-link' % project
+ '{}.egg-link'.format(project)
)
self.site_packages_egglink = os.path.join(
self.site_packages,
- '%s.egg-link' % project,
+ '{}.egg-link'.format(project),
)
# patches
diff --git a/tests/unit/test_utils_unpacking.py b/tests/unit/test_utils_unpacking.py
index af9ae1c0e..d01ffb9cd 100644
--- a/tests/unit/test_utils_unpacking.py
+++ b/tests/unit/test_utils_unpacking.py
@@ -77,7 +77,7 @@ class TestUnpackArchives(object):
continue
mode = self.mode(path)
assert mode == expected_mode, (
- "mode: %s, expected mode: %s" % (mode, expected_mode)
+ "mode: {}, expected mode: {}".format(mode, expected_mode)
)
def make_zip_file(self, filename, file_list):