diff --git a/news/f2a93c6a-3d20-4662-b510-0a11603837b1.trivial b/news/f2a93c6a-3d20-4662-b510-0a11603837b1.trivial new file mode 100644 index 000000000..e69de29bb diff --git a/src/pip/_internal/cli/base_command.py b/src/pip/_internal/cli/base_command.py index 628faa3ee..5bb8fa2bc 100644 --- a/src/pip/_internal/cli/base_command.py +++ b/src/pip/_internal/cli/base_command.py @@ -56,7 +56,7 @@ class Command(CommandContextMixIn): super(Command, self).__init__() parser_kw = { 'usage': self.usage, - 'prog': '%s %s' % (get_prog(), name), + 'prog': '{} {}'.format(get_prog(), name), 'formatter': UpdatingDefaultsHelpFormatter(), 'add_help_option': False, 'name': name, @@ -69,7 +69,7 @@ class Command(CommandContextMixIn): self.parser = ConfigOptionParser(**parser_kw) # Commands should add options to this option group - optgroup_name = '%s Options' % self.name.capitalize() + optgroup_name = '{} Options'.format(self.name.capitalize()) self.cmd_opts = optparse.OptionGroup(self.parser, optgroup_name) # Add the general options diff --git a/src/pip/_internal/cli/cmdoptions.py b/src/pip/_internal/cli/cmdoptions.py index 42e26951a..f34501990 100644 --- a/src/pip/_internal/cli/cmdoptions.py +++ b/src/pip/_internal/cli/cmdoptions.py @@ -851,12 +851,12 @@ def _handle_merge_hash(option, opt_str, value, parser): try: algo, digest = value.split(':', 1) except ValueError: - parser.error('Arguments to %s must be a hash name ' - 'followed by a value, like --hash=sha256:abcde...' % - opt_str) + parser.error('Arguments to {} must be a hash name ' + 'followed by a value, like --hash=sha256:' + 'abcde...'.format(opt_str)) if algo not in STRONG_HASHES: - parser.error('Allowed hash algorithms for %s are %s.' % - (opt_str, ', '.join(STRONG_HASHES))) + parser.error('Allowed hash algorithms for {} are {}.'.format( + opt_str, ', '.join(STRONG_HASHES))) parser.values.hashes.setdefault(algo, []).append(digest) diff --git a/src/pip/_internal/cli/main.py b/src/pip/_internal/cli/main.py index 5e97a5103..172f30dd5 100644 --- a/src/pip/_internal/cli/main.py +++ b/src/pip/_internal/cli/main.py @@ -59,7 +59,7 @@ def main(args=None): try: cmd_name, cmd_args = parse_command(args) except PipError as exc: - sys.stderr.write("ERROR: %s" % exc) + sys.stderr.write("ERROR: {}".format(exc)) sys.stderr.write(os.linesep) sys.exit(1) diff --git a/src/pip/_internal/cli/main_parser.py b/src/pip/_internal/cli/main_parser.py index a89821d44..4871956c9 100644 --- a/src/pip/_internal/cli/main_parser.py +++ b/src/pip/_internal/cli/main_parser.py @@ -86,9 +86,9 @@ def parse_command(args): if cmd_name not in commands_dict: guess = get_similar_commands(cmd_name) - msg = ['unknown command "%s"' % cmd_name] + msg = ['unknown command "{}"'.format(cmd_name)] if guess: - msg.append('maybe you meant "%s"' % guess) + msg.append('maybe you meant "{}"'.format(guess)) raise CommandError(' - '.join(msg)) diff --git a/src/pip/_internal/cli/parser.py b/src/pip/_internal/cli/parser.py index c99456bae..e799215be 100644 --- a/src/pip/_internal/cli/parser.py +++ b/src/pip/_internal/cli/parser.py @@ -33,7 +33,7 @@ class PrettyHelpFormatter(optparse.IndentedHelpFormatter): def format_option_strings(self, option): return self._format_option_strings(option, ' <%s>', ', ') - def _format_option_strings(self, option, mvarfmt=' <%s>', optsep=', '): + def _format_option_strings(self, option, mvarfmt=' <{}>', optsep=', '): """ Return a comma-separated list of option strings and metavars. @@ -52,7 +52,7 @@ class PrettyHelpFormatter(optparse.IndentedHelpFormatter): if option.takes_value(): metavar = option.metavar or option.dest.lower() - opts.append(mvarfmt % metavar.lower()) + opts.append(mvarfmt.format(metavar.lower())) return ''.join(opts) @@ -66,7 +66,8 @@ class PrettyHelpFormatter(optparse.IndentedHelpFormatter): Ensure there is only one newline between usage and the first heading if there is no description. """ - msg = '\nUsage: %s\n' % self.indent_lines(textwrap.dedent(usage), " ") + msg = '\nUsage: {}\n'.format( + self.indent_lines(textwrap.dedent(usage), " ")) return msg def format_description(self, description): @@ -82,7 +83,7 @@ class PrettyHelpFormatter(optparse.IndentedHelpFormatter): description = description.rstrip() # dedent, then reindent description = self.indent_lines(textwrap.dedent(description), " ") - description = '%s:\n%s\n' % (label, description) + description = '{}:\n{}\n'.format(label, description) return description else: return '' @@ -150,7 +151,7 @@ class ConfigOptionParser(CustomOptionParser): try: return option.check_value(key, val) except optparse.OptionValueError as exc: - print("An error occurred during configuration: %s" % exc) + print("An error occurred during configuration: {}".format(exc)) sys.exit(3) def _get_ordered_configuration_items(self): @@ -249,7 +250,7 @@ class ConfigOptionParser(CustomOptionParser): def error(self, msg): self.print_usage(sys.stderr) - self.exit(UNKNOWN_ERROR, "%s\n" % msg) + self.exit(UNKNOWN_ERROR, "{}\n".format(msg)) def invalid_config_error_message(action, key, val): diff --git a/src/pip/_internal/commands/completion.py b/src/pip/_internal/commands/completion.py index c532806e3..e0b743e54 100644 --- a/src/pip/_internal/commands/completion.py +++ b/src/pip/_internal/commands/completion.py @@ -92,5 +92,5 @@ class CompletionCommand(Command): print(BASE_COMPLETION % {'script': script, 'shell': options.shell}) else: sys.stderr.write( - 'ERROR: You must pass %s\n' % ' or '.join(shell_options) + 'ERROR: You must pass {}\n' .format(' or '.join(shell_options)) ) diff --git a/src/pip/_internal/commands/freeze.py b/src/pip/_internal/commands/freeze.py index c59eb3960..41fea20ca 100644 --- a/src/pip/_internal/commands/freeze.py +++ b/src/pip/_internal/commands/freeze.py @@ -65,7 +65,7 @@ class FreezeCommand(Command): dest='freeze_all', action='store_true', help='Do not skip these packages in the output:' - ' %s' % ', '.join(DEV_PKGS)) + ' {}'.format(', '.join(DEV_PKGS))) self.cmd_opts.add_option( '--exclude-editable', dest='exclude_editable', diff --git a/src/pip/_internal/commands/hash.py b/src/pip/_internal/commands/hash.py index 1dc7fb0ea..f26686156 100644 --- a/src/pip/_internal/commands/hash.py +++ b/src/pip/_internal/commands/hash.py @@ -34,8 +34,8 @@ class HashCommand(Command): choices=STRONG_HASHES, action='store', default=FAVORITE_HASH, - help='The hash algorithm to use: one of %s' % - ', '.join(STRONG_HASHES)) + help='The hash algorithm to use: one of {}'.format( + ', '.join(STRONG_HASHES))) self.parser.insert_option_group(0, self.cmd_opts) def run(self, options, args): diff --git a/src/pip/_internal/commands/help.py b/src/pip/_internal/commands/help.py index 75af999b4..c17d7a457 100644 --- a/src/pip/_internal/commands/help.py +++ b/src/pip/_internal/commands/help.py @@ -29,9 +29,9 @@ class HelpCommand(Command): if cmd_name not in commands_dict: guess = get_similar_commands(cmd_name) - msg = ['unknown command "%s"' % cmd_name] + msg = ['unknown command "{}"'.format(cmd_name)] if guess: - msg.append('maybe you meant "%s"' % guess) + msg.append('maybe you meant "{}"'.format(guess)) raise CommandError(' - '.join(msg)) diff --git a/src/pip/_internal/exceptions.py b/src/pip/_internal/exceptions.py index dddec789e..882529dec 100644 --- a/src/pip/_internal/exceptions.py +++ b/src/pip/_internal/exceptions.py @@ -255,8 +255,8 @@ class HashMismatch(HashError): self.gots = gots def body(self): - return ' %s:\n%s' % (self._requirement_name(), - self._hash_comparison()) + return ' {}:\n{}'.format(self._requirement_name(), + self._hash_comparison()) def _hash_comparison(self): """ @@ -277,10 +277,10 @@ class HashMismatch(HashError): lines = [] for hash_name, expecteds in iteritems(self.allowed): prefix = hash_then_or(hash_name) - lines.extend((' Expected %s %s' % (next(prefix), e)) + lines.extend((' Expected {} {}'.format(next(prefix), e)) for e in expecteds) - lines.append(' Got %s\n' % - self.gots[hash_name].hexdigest()) + lines.append(' Got {}\n'.format( + self.gots[hash_name].hexdigest())) return '\n'.join(lines) diff --git a/src/pip/_internal/index/collector.py b/src/pip/_internal/index/collector.py index 833079317..69bf738e5 100644 --- a/src/pip/_internal/index/collector.py +++ b/src/pip/_internal/index/collector.py @@ -354,7 +354,7 @@ def _get_html_page(link, session=None): reason += str(exc) _handle_get_page_fail(link, reason, meth=logger.info) except requests.ConnectionError as exc: - _handle_get_page_fail(link, "connection error: %s" % exc) + _handle_get_page_fail(link, "connection error: {}".format(exc)) except requests.Timeout: _handle_get_page_fail(link, "timed out") else: diff --git a/src/pip/_internal/index/package_finder.py b/src/pip/_internal/index/package_finder.py index a74d78db5..e88ad9f5c 100644 --- a/src/pip/_internal/index/package_finder.py +++ b/src/pip/_internal/index/package_finder.py @@ -177,9 +177,10 @@ class LinkEvaluator(object): if not ext: return (False, 'not a file') if ext not in SUPPORTED_EXTENSIONS: - return (False, 'unsupported archive format: %s' % ext) + return (False, 'unsupported archive format: {}'.format(ext)) if "binary" not in self._formats and ext == WHEEL_EXTENSION: - reason = 'No binaries permitted for %s' % self.project_name + reason = 'No binaries permitted for {}'.format( + self.project_name) return (False, reason) if "macosx10" in link.path and ext == '.zip': return (False, 'macosx10 one') @@ -189,7 +190,8 @@ class LinkEvaluator(object): except InvalidWheelFilename: return (False, 'invalid wheel filename') if canonicalize_name(wheel.name) != self._canonical_name: - reason = 'wrong project name (not %s)' % self.project_name + reason = 'wrong project name (not {})'.format( + self.project_name) return (False, reason) supported_tags = self._target_python.get_tags() @@ -208,16 +210,16 @@ class LinkEvaluator(object): # This should be up by the self.ok_binary check, but see issue 2700. if "source" not in self._formats and ext != WHEEL_EXTENSION: - return (False, 'No sources permitted for %s' % self.project_name) + reason = 'No sources permitted for {}'.format(self.project_name) + return (False, reason) if not version: version = _extract_version_from_fragment( egg_info, self._canonical_name, ) if not version: - return ( - False, 'Missing project version for %s' % self.project_name, - ) + reason = 'Missing project version for {}'.format(self.project_name) + return (False, reason) match = self._py_version_re.search(version) if match: @@ -524,8 +526,8 @@ class CandidateEvaluator(object): wheel = Wheel(link.filename) if not wheel.supported(valid_tags): raise UnsupportedWheel( - "%s is not a supported wheel for this platform. It " - "can't be sorted." % wheel.filename + "{} is not a supported wheel for this platform. It " + "can't be sorted.".format(wheel.filename) ) if self._prefer_binary: binary_preference = 1 @@ -924,7 +926,8 @@ class PackageFinder(object): ) raise DistributionNotFound( - 'No matching distribution found for %s' % req + 'No matching distribution found for {}'.format( + req) ) best_installed = False diff --git a/src/pip/_internal/models/link.py b/src/pip/_internal/models/link.py index 34fbcbfe7..1b3aa591a 100644 --- a/src/pip/_internal/models/link.py +++ b/src/pip/_internal/models/link.py @@ -66,12 +66,12 @@ class Link(KeyBasedCompareMixin): def __str__(self): # type: () -> str if self.requires_python: - rp = ' (requires-python:%s)' % self.requires_python + rp = ' (requires-python:{})'.format(self.requires_python) else: rp = '' if self.comes_from: - return '%s (from %s)%s' % (redact_auth_from_url(self._url), - self.comes_from, rp) + return '{} (from {}){}'.format( + redact_auth_from_url(self._url), self.comes_from, rp) else: return redact_auth_from_url(str(self._url)) diff --git a/src/pip/_internal/models/wheel.py b/src/pip/_internal/models/wheel.py index f1e3f44c5..4d4068f3b 100644 --- a/src/pip/_internal/models/wheel.py +++ b/src/pip/_internal/models/wheel.py @@ -30,7 +30,7 @@ class Wheel(object): wheel_info = self.wheel_file_re.match(filename) if not wheel_info: raise InvalidWheelFilename( - "%s is not a valid wheel filename." % filename + "{} is not a valid wheel filename.".format(filename) ) self.filename = filename self.name = wheel_info.group('name').replace('_', '-') diff --git a/src/pip/_internal/network/auth.py b/src/pip/_internal/network/auth.py index 1e1da54ca..94da3d46a 100644 --- a/src/pip/_internal/network/auth.py +++ b/src/pip/_internal/network/auth.py @@ -215,7 +215,7 @@ class MultiDomainBasicAuth(AuthBase): # Factored out to allow for easy patching in tests def _prompt_for_password(self, netloc): - username = ask_input("User for %s: " % netloc) + username = ask_input("User for {}: ".format(netloc)) if not username: return None, None auth = get_keyring_auth(netloc, username) diff --git a/src/pip/_internal/operations/build/wheel_legacy.py b/src/pip/_internal/operations/build/wheel_legacy.py index 3ebd9fe44..96dd09a45 100644 --- a/src/pip/_internal/operations/build/wheel_legacy.py +++ b/src/pip/_internal/operations/build/wheel_legacy.py @@ -89,7 +89,7 @@ def build_wheel_legacy( destination_dir=tempd, ) - spin_message = 'Building wheel for %s (setup.py)' % (name,) + spin_message = 'Building wheel for {} (setup.py)'.format(name) with open_spinner(spin_message) as spinner: logger.debug('Destination directory: %s', tempd) diff --git a/src/pip/_internal/operations/freeze.py b/src/pip/_internal/operations/freeze.py index 36a5c339a..5575d70d0 100644 --- a/src/pip/_internal/operations/freeze.py +++ b/src/pip/_internal/operations/freeze.py @@ -60,7 +60,7 @@ def freeze( skip_match = re.compile(skip_regex).search for link in find_links: - yield '-f %s' % link + yield '-f {}'.format(link) installations = {} # type: Dict[str, FrozenRequirement] for dist in get_installed_distributions(local_only=local_only, skip=(), @@ -261,5 +261,5 @@ class FrozenRequirement(object): def __str__(self): req = self.req if self.editable: - req = '-e %s' % req + req = '-e {}'.format(req) return '\n'.join(list(self.comments) + [str(req)]) + '\n' diff --git a/src/pip/_internal/operations/install/wheel.py b/src/pip/_internal/operations/install/wheel.py index aac975c3a..b1a76a24c 100644 --- a/src/pip/_internal/operations/install/wheel.py +++ b/src/pip/_internal/operations/install/wheel.py @@ -504,11 +504,11 @@ def install_unpacked_wheel( if os.environ.get("ENSUREPIP_OPTIONS", "") != "altinstall": scripts_to_generate.append( - 'pip%s = %s' % (sys.version_info[0], pip_script) + 'pip{} = {}'.format(sys.version_info[0], pip_script) ) scripts_to_generate.append( - 'pip%s = %s' % (get_major_minor_version(), pip_script) + 'pip{} = {}'.format(get_major_minor_version(), pip_script) ) # Delete any other versioned pip entry points pip_ep = [k for k in console if re.match(r'pip(\d(\.\d)?)?$', k)] @@ -522,7 +522,7 @@ def install_unpacked_wheel( ) scripts_to_generate.append( - 'easy_install-%s = %s' % ( + 'easy_install-{} = {}'.format( get_major_minor_version(), easy_install_script ) ) diff --git a/src/pip/_internal/req/__init__.py b/src/pip/_internal/req/__init__.py index 05e089728..d2d027ade 100644 --- a/src/pip/_internal/req/__init__.py +++ b/src/pip/_internal/req/__init__.py @@ -48,18 +48,17 @@ def install_given_reqs( """ if to_install: - msg = 'Installing collected packages: {}'.format( - ', '.join([req.name for req in to_install]) + logger.info( + 'Installing collected packages: %s', + ', '.join([req.name for req in to_install]), ) - logger.info(msg) installed = [] with indent_log(): for requirement in to_install: if requirement.should_reinstall: - logger.info('Attempting uninstall: {}'.format( - requirement.name)) + logger.info('Attempting uninstall: %s', requirement.name) with indent_log(): uninstalled_pathset = requirement.uninstall( auto_confirm=True diff --git a/src/pip/_internal/req/constructors.py b/src/pip/_internal/req/constructors.py index 1f3cd8a10..16f2c9c7d 100644 --- a/src/pip/_internal/req/constructors.py +++ b/src/pip/_internal/req/constructors.py @@ -137,16 +137,17 @@ def parse_editable(editable_req): vc_type = url.split('+', 1)[0].lower() if not vcs.get_backend(vc_type): - error_message = 'For --editable=%s only ' % editable_req + \ - ', '.join([backend.name + '+URL' for backend in vcs.backends]) + \ - ' is currently supported' + error_message = 'For --editable={} only '.format( + editable_req + ', '.join( + [backend.name + '+URL' for backend in vcs.backends]) + + ' is currently supported') raise InstallationError(error_message) package_name = Link(url).egg_fragment if not package_name: raise InstallationError( - "Could not detect requirement name for '%s', please specify one " - "with #egg=your_package_name" % editable_req + "Could not detect requirement name for '{}', please specify one " + "with #egg=your_package_name".format(editable_req) ) return package_name, url, None @@ -166,16 +167,18 @@ def deduce_helpful_msg(req): with open(req, 'r') as fp: # parse first line only next(parse_requirements(fp.read())) - msg += " The argument you provided " + \ - "(%s) appears to be a" % (req) + \ - " requirements file. If that is the" + \ - " case, use the '-r' flag to install" + \ + msg += ( + "The argument you provided " + "({}) appears to be a" + " requirements file. If that is the" + " case, use the '-r' flag to install" " the packages specified within it." + ).format(req) except RequirementParseError: logger.debug("Cannot parse '%s' as requirements \ file" % (req), exc_info=True) else: - msg += " File '%s' does not exist." % (req) + msg += " File '{}' does not exist.".format(req) return msg @@ -201,7 +204,7 @@ def parse_req_from_editable(editable_req): try: req = Requirement(name) except InvalidRequirement: - raise InstallationError("Invalid requirement: '%s'" % name) + raise InstallationError("Invalid requirement: '{}'".format(name)) else: req = None @@ -415,7 +418,7 @@ def install_req_from_req_string( try: req = Requirement(req_string) except InvalidRequirement: - raise InstallationError("Invalid requirement: '%s'" % req_string) + raise InstallationError("Invalid requirement: '{}'".format(req_string)) domains_not_allowed = [ PyPI.file_storage_domain, @@ -427,7 +430,7 @@ def install_req_from_req_string( raise InstallationError( "Packages installed from PyPI cannot depend on packages " "which are not also hosted on PyPI.\n" - "%s depends on %s " % (comes_from.name, req) + "{} depends on {} ".format(comes_from.name, req) ) return InstallRequirement( diff --git a/src/pip/_internal/req/req_file.py b/src/pip/_internal/req/req_file.py index 8c7810481..baf8d03ea 100644 --- a/src/pip/_internal/req/req_file.py +++ b/src/pip/_internal/req/req_file.py @@ -183,7 +183,7 @@ def handle_line( """ # preserve for the nested code path - line_comes_from = '%s %s (line %s)' % ( + line_comes_from = '{} {} (line {})'.format( '-c' if line.constraint else '-r', line.filename, line.lineno, ) @@ -329,7 +329,7 @@ class RequirementsFileParser(object): args_str, opts = self._line_parser(line) except OptionParsingError as e: # add offending line - msg = 'Invalid requirement: %s\n%s' % (line, e.msg) + msg = 'Invalid requirement: {}\n{}'.format(line, e.msg) raise RequirementsFileParseError(msg) yield ParsedLine( @@ -520,8 +520,9 @@ def get_file_content(url, session, comes_from=None): elif scheme == 'file': if comes_from and comes_from.startswith('http'): raise InstallationError( - 'Requirements file %s references URL %s, which is local' - % (comes_from, url)) + 'Requirements file {} references URL {}, ' + 'which is local'.format(comes_from, url) + ) path = url.split(':', 1)[1] path = path.replace('\\', '/') @@ -538,7 +539,7 @@ def get_file_content(url, session, comes_from=None): content = auto_decode(f.read()) except IOError as exc: raise InstallationError( - 'Could not open requirements file: %s' % str(exc) + 'Could not open requirements file: {}'.format(exc) ) return url, content diff --git a/src/pip/_internal/req/req_install.py b/src/pip/_internal/req/req_install.py index 6bbad8857..e560cf449 100644 --- a/src/pip/_internal/req/req_install.py +++ b/src/pip/_internal/req/req_install.py @@ -195,25 +195,25 @@ class InstallRequirement(object): if self.req: s = str(self.req) if self.link: - s += ' from %s' % redact_auth_from_url(self.link.url) + s += ' from {}'.format(redact_auth_from_url(self.link.url)) elif self.link: s = redact_auth_from_url(self.link.url) else: s = '' if self.satisfied_by is not None: - s += ' in %s' % display_path(self.satisfied_by.location) + s += ' in {}'.format(display_path(self.satisfied_by.location)) if self.comes_from: if isinstance(self.comes_from, six.string_types): comes_from = self.comes_from # type: Optional[str] else: comes_from = self.comes_from.from_path() if comes_from: - s += ' (from %s)' % comes_from + s += ' (from {})'.format(comes_from) return s def __repr__(self): # type: () -> str - return '<%s object: %s editable=%r>' % ( + return '<{} object: {} editable={!r}>'.format( self.__class__.__name__, str(self), self.editable) def format_debug(self): @@ -452,8 +452,8 @@ class InstallRequirement(object): dist_in_site_packages(existing_dist)): raise InstallationError( "Will not install to the user site because it will " - "lack sys.path precedence to %s in %s" % - (existing_dist.project_name, existing_dist.location) + "lack sys.path precedence to {} in {}".format( + existing_dist.project_name, existing_dist.location) ) else: self.should_reinstall = True @@ -483,7 +483,7 @@ class InstallRequirement(object): @property def setup_py_path(self): # type: () -> str - assert self.source_dir, "No source dir for %s" % self + assert self.source_dir, "No source dir for {}".format(self) setup_py = os.path.join(self.unpacked_source_directory, 'setup.py') # Python2 __file__ should not be unicode @@ -495,7 +495,7 @@ class InstallRequirement(object): @property def pyproject_toml_path(self): # type: () -> str - assert self.source_dir, "No source dir for %s" % self + assert self.source_dir, "No source dir for {}".format(self) return make_pyproject_path(self.unpacked_source_directory) def load_pyproject_toml(self): @@ -654,8 +654,8 @@ class InstallRequirement(object): vcs_backend.export(self.source_dir, url=hidden_url) else: assert 0, ( - 'Unexpected version control type (in %s): %s' - % (self.link, vc_type)) + 'Unexpected version control type (in {}): {}'.format( + self.link, vc_type)) # Top-level Actions def uninstall(self, auto_confirm=False, verbose=False): @@ -710,13 +710,15 @@ class InstallRequirement(object): assert self.source_dir create_archive = True - archive_name = '%s-%s.zip' % (self.name, self.metadata["version"]) + archive_name = '{}-{}.zip'.format(self.name, self.metadata["version"]) archive_path = os.path.join(build_dir, archive_name) if os.path.exists(archive_path): response = ask_path_exists( - 'The file %s exists. (i)gnore, (w)ipe, (b)ackup, (a)bort ' % - display_path(archive_path), ('i', 'w', 'b', 'a')) + 'The file {} exists. (i)gnore, (w)ipe, ' + '(b)ackup, (a)bort '.format( + display_path(archive_path)), + ('i', 'w', 'b', 'a')) if response == 'i': create_archive = False elif response == 'w': diff --git a/src/pip/_internal/req/req_set.py b/src/pip/_internal/req/req_set.py index 087ac5925..1312622b8 100644 --- a/src/pip/_internal/req/req_set.py +++ b/src/pip/_internal/req/req_set.py @@ -108,8 +108,8 @@ class RequirementSet(object): tags = pep425tags.get_supported() if (self.check_supported_wheels and not wheel.supported(tags)): raise InstallationError( - "%s is not a supported wheel on this platform." % - wheel.filename + "{} is not a supported wheel on this platform.".format( + wheel.filename) ) # This next bit is really a sanity check. @@ -138,8 +138,8 @@ class RequirementSet(object): ) if has_conflicting_requirement: raise InstallationError( - "Double requirement given: %s (already in %s, name=%r)" - % (install_req, existing_req, install_req.name) + "Double requirement given: {} (already in {}, name={!r})" + .format(install_req, existing_req, install_req.name) ) # When no existing requirement exists, add the requirement as a @@ -164,9 +164,9 @@ class RequirementSet(object): if does_not_satisfy_constraint: self.reqs_to_cleanup.append(install_req) raise InstallationError( - "Could not satisfy constraints for '%s': " + "Could not satisfy constraints for '{}': " "installation from path or url cannot be " - "constrained to a version" % install_req.name, + "constrained to a version".format(install_req.name) ) # If we're now installing a constraint, mark the existing # object for real installation. diff --git a/src/pip/_internal/req/req_tracker.py b/src/pip/_internal/req/req_tracker.py index d72a41d20..14adeab29 100644 --- a/src/pip/_internal/req/req_tracker.py +++ b/src/pip/_internal/req/req_tracker.py @@ -60,7 +60,7 @@ def get_requirement_tracker(): TempDirectory(kind='req-tracker') ).path ctx.enter_context(update_env_context_manager(PIP_REQ_TRACKER=root)) - logger.debug("Initialized build tracking at {}".format(root)) + logger.debug("Initialized build tracking at %s", root) with RequirementTracker(root) as tracker: yield tracker @@ -111,7 +111,8 @@ class RequirementTracker(object): if e.errno != errno.ENOENT: raise else: - message = '%s is already being built: %s' % (req.link, contents) + message = '{} is already being built: {}'.format( + req.link, contents) raise LookupError(message) # If we're here, req should really not be building already. diff --git a/src/pip/_internal/req/req_uninstall.py b/src/pip/_internal/req/req_uninstall.py index 5971b130e..ec9da2c34 100644 --- a/src/pip/_internal/req/req_uninstall.py +++ b/src/pip/_internal/req/req_uninstall.py @@ -540,8 +540,9 @@ class UninstallPathSet(object): with open(develop_egg_link, 'r') as fh: link_pointer = os.path.normcase(fh.readline().strip()) assert (link_pointer == dist.location), ( - 'Egg-link %s does not match installed location of %s ' - '(at %s)' % (link_pointer, dist.project_name, dist.location) + 'Egg-link {} does not match installed location of {} ' + '(at {})'.format( + link_pointer, dist.project_name, dist.location) ) paths_to_remove.add(develop_egg_link) easy_install_pth = os.path.join(os.path.dirname(develop_egg_link), @@ -586,7 +587,8 @@ class UninstallPthEntries(object): # type: (str) -> None if not os.path.isfile(pth_file): raise UninstallationError( - "Cannot remove entries from nonexistent file %s" % pth_file + "Cannot remove entries from nonexistent file {}".format( + pth_file) ) self.file = pth_file self.entries = set() # type: Set[str] diff --git a/src/pip/_internal/utils/compat.py b/src/pip/_internal/utils/compat.py index 6efa52ad2..08c292d18 100644 --- a/src/pip/_internal/utils/compat.py +++ b/src/pip/_internal/utils/compat.py @@ -184,7 +184,8 @@ def get_path_uid(path): else: # raise OSError for parity with os.O_NOFOLLOW above raise OSError( - "%s is a symlink; Will not return uid for symlinks" % path + "{} is a symlink; Will not return uid for symlinks".format( + path) ) return file_uid diff --git a/src/pip/_internal/utils/hashes.py b/src/pip/_internal/utils/hashes.py index 4c41551a2..396cf82e7 100644 --- a/src/pip/_internal/utils/hashes.py +++ b/src/pip/_internal/utils/hashes.py @@ -73,7 +73,9 @@ class Hashes(object): try: gots[hash_name] = hashlib.new(hash_name) except (ValueError, TypeError): - raise InstallationError('Unknown hash name: %s' % hash_name) + raise InstallationError( + 'Unknown hash name: {}'.format(hash_name) + ) for chunk in chunks: for hash in itervalues(gots): diff --git a/src/pip/_internal/utils/misc.py b/src/pip/_internal/utils/misc.py index 4a5816019..667ed80a3 100644 --- a/src/pip/_internal/utils/misc.py +++ b/src/pip/_internal/utils/misc.py @@ -120,7 +120,7 @@ def get_prog(): try: prog = os.path.basename(sys.argv[0]) if prog in ('__main__.py', '-c'): - return "%s -m pip" % sys.executable + return "{} -m pip".format(sys.executable) else: return prog except (AttributeError, TypeError, IndexError): @@ -228,8 +228,8 @@ def _check_no_input(message): """Raise an error if no input is allowed.""" if os.environ.get('PIP_NO_INPUT'): raise Exception( - 'No input was expected ($PIP_NO_INPUT set); question: %s' % - message + 'No input was expected ($PIP_NO_INPUT set); question: {}'.format( + message) ) @@ -242,8 +242,8 @@ def ask(message, options): response = response.strip().lower() if response not in options: print( - 'Your response (%r) was not one of the expected responses: ' - '%s' % (response, ', '.join(options)) + 'Your response ({!r}) was not one of the expected responses: ' + '{}'.format(response, ', '.join(options)) ) else: return response diff --git a/src/pip/_internal/utils/subprocess.py b/src/pip/_internal/utils/subprocess.py index ea0176d34..61c40a49e 100644 --- a/src/pip/_internal/utils/subprocess.py +++ b/src/pip/_internal/utils/subprocess.py @@ -242,14 +242,14 @@ def call_subprocess( raise InstallationError(exc_msg) elif on_returncode == 'warn': subprocess_logger.warning( - 'Command "%s" had error code %s in %s', - command_desc, proc.returncode, cwd, + 'Command "{}" had error code {} in {}'.format( + command_desc, proc.returncode, cwd) ) elif on_returncode == 'ignore': pass else: - raise ValueError('Invalid value: on_returncode=%s' % - repr(on_returncode)) + raise ValueError('Invalid value: on_returncode={!r}'.format( + on_returncode)) return ''.join(all_output) diff --git a/src/pip/_internal/utils/ui.py b/src/pip/_internal/utils/ui.py index 87782aa64..f84feb317 100644 --- a/src/pip/_internal/utils/ui.py +++ b/src/pip/_internal/utils/ui.py @@ -153,7 +153,7 @@ class DownloadProgressMixin(object): @property def pretty_eta(self): if self.eta: - return "eta %s" % self.eta_td + return "eta {}".format(self.eta_td) return "" def iter(self, it): @@ -399,7 +399,7 @@ class NonInteractiveSpinner(SpinnerInterface): # type: (str) -> None if self._finished: return - self._update("finished with status '%s'" % (final_status,)) + self._update("finished with status '{}'".format(final_status)) self._finished = True diff --git a/src/pip/_internal/utils/wheel.py b/src/pip/_internal/utils/wheel.py index 837e0afd7..e4166a68e 100644 --- a/src/pip/_internal/utils/wheel.py +++ b/src/pip/_internal/utils/wheel.py @@ -215,8 +215,8 @@ def check_compatibility(version, name): """ if version[0] > VERSION_COMPATIBLE[0]: raise UnsupportedWheel( - "%s's Wheel-Version (%s) is not compatible with this version " - "of pip" % (name, '.'.join(map(str, version))) + "{}'s Wheel-Version ({}) is not compatible with this version " + "of pip".format(name, '.'.join(map(str, version))) ) elif version > VERSION_COMPATIBLE: logger.warning( diff --git a/src/pip/_internal/vcs/versioncontrol.py b/src/pip/_internal/vcs/versioncontrol.py index 7cfd56882..1ec986ba5 100644 --- a/src/pip/_internal/vcs/versioncontrol.py +++ b/src/pip/_internal/vcs/versioncontrol.py @@ -574,7 +574,8 @@ class VersionControl(object): self.name, url, ) - response = ask_path_exists('What to do? %s' % prompt[0], prompt[1]) + response = ask_path_exists('What to do? {}'.format( + prompt[0]), prompt[1]) if response == 'a': sys.exit(-1)