diff --git a/src/pip/_internal/__init__.py b/src/pip/_internal/__init__.py index 532edd26c85..fede520fad7 100755 --- a/src/pip/_internal/__init__.py +++ b/src/pip/_internal/__init__.py @@ -29,8 +29,8 @@ except ImportError: pass else: - if (sys.platform == "darwin" and - ssl.OPENSSL_VERSION_NUMBER < 0x1000100f): # OpenSSL 1.0.1 + # Checks for OpenSSL 1.0.1 on MacOS + if sys.platform == "darwin" and ssl.OPENSSL_VERSION_NUMBER < 0x1000100f: try: from pip._vendor.urllib3.contrib import securetransport except (ImportError, OSError): @@ -148,7 +148,8 @@ def create_main_parser(): pip_pkg_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) parser.version = 'pip %s from %s (python %s)' % ( - __version__, pip_pkg_dir, sys.version[:3]) + __version__, pip_pkg_dir, sys.version[:3], + ) # add the general options gen_opts = cmdoptions.make_option_group(cmdoptions.general_group, parser) diff --git a/src/pip/_internal/cmdoptions.py b/src/pip/_internal/cmdoptions.py index eaabdbde6fc..28d36fed6f9 100644 --- a/src/pip/_internal/cmdoptions.py +++ b/src/pip/_internal/cmdoptions.py @@ -56,7 +56,8 @@ def getname(n): fmt_ctl_no_binary(control) warnings.warn( 'Disabling all use of wheels due to the use of --build-options ' - '/ --global-options / --install-options.', stacklevel=2) + '/ --global-options / --install-options.', stacklevel=2, + ) ########### @@ -366,13 +367,15 @@ def _get_format_control(values, option): def _handle_no_binary(option, opt_str, value, parser): existing = getattr(parser.values, option.dest) fmt_ctl_handle_mutual_exclude( - value, existing.no_binary, existing.only_binary) + value, existing.no_binary, existing.only_binary, + ) def _handle_only_binary(option, opt_str, value, parser): existing = getattr(parser.values, option.dest) fmt_ctl_handle_mutual_exclude( - value, existing.only_binary, existing.no_binary) + value, existing.only_binary, existing.no_binary, + ) def no_binary(): diff --git a/src/pip/_internal/commands/check.py b/src/pip/_internal/commands/check.py index ea7dc909439..945af705acb 100644 --- a/src/pip/_internal/commands/check.py +++ b/src/pip/_internal/commands/check.py @@ -22,14 +22,16 @@ def run(self, options, args): for requirement in missing_reqs_dict.get(dist.key, []): logger.info( "%s %s requires %s, which is not installed.", - dist.project_name, dist.version, requirement.project_name) + dist.project_name, dist.version, requirement.project_name, + ) for requirement, actual in incompatible_reqs_dict.get( dist.key, []): logger.info( "%s %s has requirement %s, but you have %s %s.", dist.project_name, dist.version, requirement, - actual.project_name, actual.version) + actual.project_name, actual.version, + ) if missing_reqs_dict or incompatible_reqs_dict: return 1 diff --git a/src/pip/_internal/commands/download.py b/src/pip/_internal/commands/download.py index e64912e4173..f05f6447c2a 100644 --- a/src/pip/_internal/commands/download.py +++ b/src/pip/_internal/commands/download.py @@ -222,9 +222,7 @@ def run(self, options, args): req.name for req in requirement_set.successfully_downloaded ]) if downloaded: - logger.info( - 'Successfully downloaded %s', downloaded - ) + logger.info('Successfully downloaded %s', downloaded) # Clean up if not options.no_clean: diff --git a/src/pip/_internal/commands/freeze.py b/src/pip/_internal/commands/freeze.py index 2ac0bf9ca7e..5c0e339705d 100644 --- a/src/pip/_internal/commands/freeze.py +++ b/src/pip/_internal/commands/freeze.py @@ -86,7 +86,8 @@ def run(self, options, args): isolated=options.isolated_mode, wheel_cache=wheel_cache, skip=skip, - exclude_editable=options.exclude_editable) + exclude_editable=options.exclude_editable, + ) for line in freeze(**freeze_kwargs): sys.stdout.write(line + '\n') diff --git a/src/pip/_internal/compat.py b/src/pip/_internal/compat.py index fdbfb7dd8d1..70d7730f666 100644 --- a/src/pip/_internal/compat.py +++ b/src/pip/_internal/compat.py @@ -60,7 +60,8 @@ def backslashreplace_decode_fn(err): return u"".join(u"\\x%x" % c for c in raw_bytes), err.end codecs.register_error( "backslashreplace_decode", - backslashreplace_decode_fn) + backslashreplace_decode_fn, + ) backslashreplace_decode = "backslashreplace_decode" @@ -88,8 +89,9 @@ def console_to_str(data): s = data.decode(encoding) except UnicodeDecodeError: logger.warning( - "Subprocess output does not appear to be encoded as %s" % - encoding) + "Subprocess output does not appear to be encoded as %s", + encoding, + ) s = data.decode(encoding, errors=backslashreplace_decode) # Make sure we can print the output, by encoding it to the output diff --git a/src/pip/_internal/download.py b/src/pip/_internal/download.py index 9da45eac3d8..d6a4358798d 100644 --- a/src/pip/_internal/download.py +++ b/src/pip/_internal/download.py @@ -348,8 +348,8 @@ def __init__(self, *args, **kwargs): # connection got interrupted in some way. A 503 error in general # is typically considered a transient error so we'll go ahead and # retry it. - # A 500 may indicate transient errror in Amazon S3 - # A 520 or 527 - may indicate transient errror in CloudFlare + # A 500 may indicate transient error in Amazon S3 + # A 520 or 527 - may indicate transient error in CloudFlare status_forcelist=[500, 503, 520, 527], # Add a small amount of back off between failed requests in diff --git a/src/pip/_internal/index.py b/src/pip/_internal/index.py index 7c2d5cf0c2f..ab3a967b13c 100644 --- a/src/pip/_internal/index.py +++ b/src/pip/_internal/index.py @@ -253,14 +253,16 @@ def sort_path(path): else: logger.warning( "Url '%s' is ignored: it is neither a file " - "nor a directory.", url) + "nor a directory.", url, + ) elif is_url(url): # Only add url with clear scheme urls.append(url) else: logger.warning( "Url '%s' is ignored. It is either a non-existing " - "path or lacks a specific scheme.", url) + "path or lacks a specific scheme.", url, + ) return files, urls @@ -400,13 +402,13 @@ def find_all_candidates(self, project_name): index_locations = self._get_index_urls_locations(project_name) index_file_loc, index_url_loc = self._sort_locations(index_locations) fl_file_loc, fl_url_loc = self._sort_locations( - self.find_links, expand_dir=True) + self.find_links, expand_dir=True, + ) dep_file_loc, dep_url_loc = self._sort_locations(self.dependency_links) - file_locations = ( - Link(url) for url in itertools.chain( - index_file_loc, fl_file_loc, dep_file_loc) - ) + file_locations = (Link(url) for url in itertools.chain( + index_file_loc, fl_file_loc, dep_file_loc, + )) # We trust every url that the user has given us whether it was given # via --index-url or --find-links @@ -632,11 +634,13 @@ def _link_package_versions(self, link, search): return if ext not in SUPPORTED_EXTENSIONS: self._log_skipped_link( - link, 'unsupported archive format: %s' % ext) + link, 'unsupported archive format: %s' % ext, + ) return if "binary" not in search.formats and ext == wheel_ext: self._log_skipped_link( - link, 'No binaries permitted for %s' % search.supplied) + link, 'No binaries permitted for %s' % search.supplied, + ) return if "macosx10" in link.path and ext == '.zip': self._log_skipped_link(link, 'macosx10 one') @@ -662,7 +666,8 @@ def _link_package_versions(self, link, search): # This should be up by the search.ok_binary check, but see issue 2700. if "source" not in search.formats and ext != wheel_ext: self._log_skipped_link( - link, 'No sources permitted for %s' % search.supplied) + link, 'No sources permitted for %s' % search.supplied, + ) return if not version: @@ -829,8 +834,8 @@ def get_page(cls, link, skip_archives=True, session=None): except requests.HTTPError as exc: cls._handle_fail(link, exc, url) except SSLError as exc: - reason = ("There was a problem confirming the ssl certificate: " - "%s" % exc) + reason = "There was a problem confirming the ssl certificate: " + reason += str(exc) cls._handle_fail(link, reason, url, meth=logger.info) except requests.ConnectionError as exc: cls._handle_fail(link, "connection error: %s" % exc, url) @@ -1098,7 +1103,8 @@ def fmt_ctl_formats(fmt_ctl, canonical_name): def fmt_ctl_no_binary(fmt_ctl): fmt_ctl_handle_mutual_exclude( - ':all:', fmt_ctl.no_binary, fmt_ctl.only_binary) + ':all:', fmt_ctl.no_binary, fmt_ctl.only_binary, + ) Search = namedtuple('Search', 'supplied canonical formats') diff --git a/src/pip/_internal/operations/check.py b/src/pip/_internal/operations/check.py index eef0630fc0a..3855f34edbf 100644 --- a/src/pip/_internal/operations/check.py +++ b/src/pip/_internal/operations/check.py @@ -9,8 +9,7 @@ def check_requirements(installed_dists): if missing_reqs: missing_reqs_dict[dist.key] = missing_reqs - incompatible_reqs = list(get_incompatible_reqs( - dist, installed_dists)) + incompatible_reqs = list(get_incompatible_reqs(dist, installed_dists)) if incompatible_reqs: incompatible_reqs_dict[dist.key] = incompatible_reqs diff --git a/src/pip/_internal/operations/freeze.py b/src/pip/_internal/operations/freeze.py index 4455f0c910c..b6821c0e7ef 100644 --- a/src/pip/_internal/operations/freeze.py +++ b/src/pip/_internal/operations/freeze.py @@ -209,7 +209,8 @@ def from_dist(cls, dist, dependency_links): ) if not svn_location: logger.warning( - 'Warning: cannot find svn location for %s', req) + 'Warning: cannot find svn location for %s', req, + ) comments.append( '## FIXME: could not find svn URL in dependency_links ' 'for this package:' diff --git a/src/pip/_internal/req/req_file.py b/src/pip/_internal/req/req_file.py index 44cccf0cc36..08e1b119f0a 100644 --- a/src/pip/_internal/req/req_file.py +++ b/src/pip/_internal/req/req_file.py @@ -131,7 +131,8 @@ def process_line(line, filename, line_number, finder=None, comes_from=None, # preserve for the nested code path line_comes_from = '%s %s (line %s)' % ( - '-c' if constraint else '-r', filename, line_number) + '-c' if constraint else '-r', filename, line_number, + ) # yield a line requirement if args_str: @@ -299,7 +300,5 @@ def skip_regex(lines_enum, options): skip_regex = options.skip_requirements_regex if options else None if skip_regex: pattern = re.compile(skip_regex) - lines_enum = filterfalse( - lambda e: pattern.search(e[1]), - lines_enum) + lines_enum = filterfalse(lambda e: pattern.search(e[1]), lines_enum) return lines_enum diff --git a/src/pip/_internal/req/req_install.py b/src/pip/_internal/req/req_install.py index 27978d8cbf8..4f6ce4f3e58 100644 --- a/src/pip/_internal/req/req_install.py +++ b/src/pip/_internal/req/req_install.py @@ -729,7 +729,8 @@ def install(self, install_options, global_options=None, root=None, global_options = global_options if global_options is not None else [] if self.editable: self.install_editable( - install_options, global_options, prefix=prefix) + install_options, global_options, prefix=prefix, + ) return if self.is_wheel: version = wheel.wheel_version(self.source_dir) @@ -756,7 +757,8 @@ def install(self, install_options, global_options=None, root=None, with TempDirectory(kind="record") as temp_dir: record_filename = os.path.join(temp_dir.path, 'install-record.txt') install_args = self.get_install_args( - global_options, record_filename, root, prefix) + global_options, record_filename, root, prefix, + ) msg = 'Running setup.py install for %s' % (self.name,) with open_spinner(msg) as spinner: with indent_log(): @@ -882,7 +884,8 @@ def install_editable(self, install_options, list(install_options), cwd=self.setup_py_dir, - show_stdout=False) + show_stdout=False, + ) self.install_succeeded = True @@ -953,7 +956,8 @@ def get_dist(self): return pkg_resources.Distribution( os.path.dirname(egg_info), project_name=dist_name, - metadata=metadata) + metadata=metadata, + ) @property def has_hash_options(self): diff --git a/src/pip/_internal/req/req_set.py b/src/pip/_internal/req/req_set.py index fb07120e880..fdc293e002e 100644 --- a/src/pip/_internal/req/req_set.py +++ b/src/pip/_internal/req/req_set.py @@ -120,7 +120,8 @@ def add_requirement(self, install_req, parent_req_name=None, raise InstallationError( "Could not satisfy constraints for '%s': " "installation from path or url cannot be " - "constrained to a version" % name) + "constrained to a version" % name, + ) # If we're now installing a constraint, mark the existing # object for real installation. existing_req.constraint = False diff --git a/src/pip/_internal/req/req_uninstall.py b/src/pip/_internal/req/req_uninstall.py index 745d4084454..a3cc7bf66b5 100644 --- a/src/pip/_internal/req/req_uninstall.py +++ b/src/pip/_internal/req/req_uninstall.py @@ -371,7 +371,8 @@ def from_dist(cls, dist): else: logger.debug( 'Not sure how to uninstall: %s - Check: %s', - dist, dist.location) + dist, dist.location, + ) # find distutils scripts= scripts if dist.has_metadata('scripts') and dist.metadata_isdir('scripts'): diff --git a/src/pip/_internal/utils/misc.py b/src/pip/_internal/utils/misc.py index 6f7aa73e63d..6b711696520 100644 --- a/src/pip/_internal/utils/misc.py +++ b/src/pip/_internal/utils/misc.py @@ -679,7 +679,8 @@ def call_subprocess(cmd, show_stdout=True, cwd=None, try: proc = subprocess.Popen( cmd, stderr=subprocess.STDOUT, stdin=None, stdout=stdout, - cwd=cwd, env=env) + cwd=cwd, env=env, + ) except Exception as exc: logger.critical( "Error %s while executing command %s", exc, command_desc, diff --git a/src/pip/_internal/utils/packaging.py b/src/pip/_internal/utils/packaging.py index 1df474a8006..98cdb682001 100644 --- a/src/pip/_internal/utils/packaging.py +++ b/src/pip/_internal/utils/packaging.py @@ -56,8 +56,9 @@ def check_dist_requires_python(dist): ) except specifiers.InvalidSpecifier as e: logger.warning( - "Package %s has an invalid Requires-Python entry %s - %s" % ( - dist.project_name, requires_python, e)) + "Package %s has an invalid Requires-Python entry %s - %s", + dist.project_name, requires_python, e, + ) return diff --git a/src/pip/_internal/vcs/bazaar.py b/src/pip/_internal/vcs/bazaar.py index 7acaf167f85..b4e46e0e1cd 100644 --- a/src/pip/_internal/vcs/bazaar.py +++ b/src/pip/_internal/vcs/bazaar.py @@ -91,7 +91,8 @@ def get_url(self, location): def get_revision(self, location): revision = self.run_command( - ['revno'], show_stdout=False, cwd=location) + ['revno'], show_stdout=False, cwd=location, + ) return revision.splitlines()[-1] def get_src_requirement(self, dist, location): diff --git a/src/pip/_internal/vcs/git.py b/src/pip/_internal/vcs/git.py index d7bc30603cd..3528d8fd9b3 100644 --- a/src/pip/_internal/vcs/git.py +++ b/src/pip/_internal/vcs/git.py @@ -205,7 +205,8 @@ def get_url(self, location): """Return URL of the first remote encountered.""" remotes = self.run_command( ['config', '--get-regexp', r'remote\..*\.url'], - show_stdout=False, cwd=location) + show_stdout=False, cwd=location, + ) remotes = remotes.splitlines() found_remote = remotes[0] for remote in remotes: @@ -217,7 +218,8 @@ def get_url(self, location): def get_revision(self, location): current_rev = self.run_command( - ['rev-parse', 'HEAD'], show_stdout=False, cwd=location) + ['rev-parse', 'HEAD'], show_stdout=False, cwd=location, + ) return current_rev.strip() def _get_subdirectory(self, location): diff --git a/src/pip/_internal/wheel.py b/src/pip/_internal/wheel.py index c8887ff10a1..c8fc21518fd 100644 --- a/src/pip/_internal/wheel.py +++ b/src/pip/_internal/wheel.py @@ -811,7 +811,8 @@ def build(self, requirements, session, autobuilding=False): if req.is_wheel: if not autobuilding: logger.info( - 'Skipping %s, due to already being wheel.', req.name) + 'Skipping %s, due to already being wheel.', req.name, + ) elif autobuilding and req.editable: pass elif autobuilding and req.link and not req.link.is_artifact: @@ -831,7 +832,8 @@ def build(self, requirements, session, autobuilding=False): canonicalize_name(req.name)): logger.info( "Skipping bdist_wheel for %s, due to binaries " - "being disabled for it.", req.name) + "being disabled for it.", req.name, + ) continue buildset.append(req) @@ -888,7 +890,8 @@ def build(self, requirements, session, autobuilding=False): # extract the wheel into the dir unpack_url( req.link, req.source_dir, None, False, - session=session) + session=session, + ) else: build_failure.append(req) diff --git a/tests/unit/test_compat.py b/tests/unit/test_compat.py index 71d3d576267..37af0f95092 100644 --- a/tests/unit/test_compat.py +++ b/tests/unit/test_compat.py @@ -59,7 +59,7 @@ def test_console_to_str(monkeypatch): def test_console_to_str_warning(monkeypatch): some_bytes = b"a\xE9b" - def check_warning(msg): + def check_warning(msg, *args, **kwargs): assert msg.startswith( "Subprocess output does not appear to be encoded as")