Skip to content

Commit

Permalink
Update old-style formatting to new-style formatting (#7762)
Browse files Browse the repository at this point in the history
  • Loading branch information
anudit authored Feb 21, 2020
1 parent ce1e0f4 commit 082c0f0
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion docs/pip_sphinxext.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Empty file.
10 changes: 5 additions & 5 deletions src/pip/_internal/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/models/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __str__(self):

def __repr__(self):
# type: () -> str
return '<Link %s>' % self
return '<Link {}>'.format(self)

@property
def url(self):
Expand Down
8 changes: 4 additions & 4 deletions src/pip/_internal/req/constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions tests/unit/test_req.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -506,31 +506,31 @@ 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'}

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'}

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'}

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'}
Expand Down
14 changes: 7 additions & 7 deletions tests/unit/test_req_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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'
Expand All @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_utils_unpacking.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 082c0f0

Please sign in to comment.