diff --git a/docs/pip_sphinxext.py b/docs/pip_sphinxext.py
index bfc5a6b4aef..a0e69c6e4c2 100644
--- a/docs/pip_sphinxext.py
+++ b/docs/pip_sphinxext.py
@@ -55,7 +55,7 @@ def _format_option(self, option, cmd_name=None):
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 00000000000..e69de29bb2d
diff --git a/src/pip/_internal/exceptions.py b/src/pip/_internal/exceptions.py
index 882529dece7..115f7eb0c6b 100644
--- a/src/pip/_internal/exceptions.py
+++ b/src/pip/_internal/exceptions.py
@@ -150,10 +150,10 @@ def body(self):
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 @@ def body(self):
# 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 1b3aa591ab0..0b30ab2511a 100644
--- a/src/pip/_internal/models/link.py
+++ b/src/pip/_internal/models/link.py
@@ -77,7 +77,7 @@ def __str__(self):
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 c350aaa8da7..ddceabfd7c2 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 29a23926257..8ef40833ad0 100644
--- a/tests/unit/test_req.py
+++ b/tests/unit/test_req.py
@@ -449,14 +449,14 @@ def test_markers_semicolon(self):
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 @@ def test_markers_match(self):
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 @@ def test_extras_for_line_path_requirement(self):
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 @@ def test_extras_for_line_url_requirement(self):
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 @@ def test_extras_for_editable_path_requirement(self):
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 597fc2f82f2..846aeaeff09 100644
--- a/tests/unit/test_req_file.py
+++ b/tests/unit/test_req_file.py
@@ -249,21 +249,21 @@ def test_error_message(self, line_processor):
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 @@ def test_yield_line_requirement_with_spaces_in_specifier(
):
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 @@ def test_yield_editable_requirement(self, line_processor):
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 011543bdcc5..fa042519ee9 100644
--- a/tests/unit/test_utils.py
+++ b/tests/unit/test_utils.py
@@ -66,11 +66,11 @@ def setup(self):
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 af9ae1c0e71..d01ffb9cd0b 100644
--- a/tests/unit/test_utils_unpacking.py
+++ b/tests/unit/test_utils_unpacking.py
@@ -77,7 +77,7 @@ def confirm_files(self):
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):