Skip to content

Commit 0bc8aa5

Browse files
committed
Style fixes for the latest flake8
1 parent c1c638b commit 0bc8aa5

17 files changed

+160
-159
lines changed

pip/basecommand.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ def main(self, args):
220220
sys.exit(VIRTUALENV_NOT_FOUND)
221221

222222
# Check if we're using the latest version of pip available
223-
if (not options.disable_pip_version_check
224-
and not getattr(options, "no_index", False)):
223+
if (not options.disable_pip_version_check and not
224+
getattr(options, "no_index", False)):
225225
with self._build_session(
226226
options,
227227
retries=0,

pip/commands/install.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ def run(self, options, args):
211211

212212
# If we have --no-install or --no-download and no --build we use the
213213
# legacy static build dir
214-
if (options.build_dir is None
215-
and (options.no_install or options.no_download)):
214+
if (options.build_dir is None and
215+
(options.no_install or options.no_download)):
216216
options.build_dir = build_prefix
217217

218218
if options.download_dir:
@@ -237,8 +237,8 @@ def run(self, options, args):
237237
options.ignore_installed = True
238238
temp_target_dir = tempfile.mkdtemp()
239239
options.target_dir = os.path.abspath(options.target_dir)
240-
if (os.path.exists(options.target_dir)
241-
and not os.path.isdir(options.target_dir)):
240+
if (os.path.exists(options.target_dir) and not
241+
os.path.isdir(options.target_dir)):
242242
raise CommandError(
243243
"Target path exists but is not a directory, will not "
244244
"continue."
@@ -376,9 +376,9 @@ def run(self, options, args):
376376
raise
377377
finally:
378378
# Clean up
379-
if ((not options.no_clean)
380-
and ((not options.no_install)
381-
or options.download_dir)):
379+
if ((not options.no_clean) and
380+
((not options.no_install) or
381+
options.download_dir)):
382382
requirement_set.cleanup_files()
383383

384384
if options.target_dir:

pip/commands/zip.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ def run(self, options, args):
152152

153153
def unzip_package(self, module_name, filename):
154154
zip_filename = os.path.dirname(filename)
155-
if (not os.path.isfile(zip_filename)
156-
and zipfile.is_zipfile(zip_filename)):
155+
if (not os.path.isfile(zip_filename) and
156+
zipfile.is_zipfile(zip_filename)):
157157
raise InstallationError(
158158
'Module %s (in %s) isn\'t located in a zip file in %s'
159159
% (module_name, filename, zip_filename))
@@ -355,9 +355,9 @@ def list(self, options, args):
355355
if os.path.dirname(path) not in self.paths():
356356
logger.info('Zipped egg: %s', display_path(path))
357357
continue
358-
if (basename != 'site-packages'
359-
and basename != 'dist-packages'
360-
and not path.replace('\\', '/').endswith('lib/python')):
358+
if (basename != 'site-packages' and
359+
basename != 'dist-packages' and not
360+
path.replace('\\', '/').endswith('lib/python')):
361361
continue
362362
logger.info('In %s:', display_path(path))
363363

pip/compat/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,5 @@ def get_path_uid(path):
9999

100100

101101
# windows detection, covers cpython and ironpython
102-
WINDOWS = (sys.platform.startswith("win")
103-
or (sys.platform == 'cli' and os.name == 'nt'))
102+
WINDOWS = (sys.platform.startswith("win") or
103+
(sys.platform == 'cli' and os.name == 'nt'))

pip/download.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,8 @@ def get_file_content(url, comes_from=None, session=None):
376376
match = _scheme_re.search(url)
377377
if match:
378378
scheme = match.group(1).lower()
379-
if (scheme == 'file' and comes_from
380-
and comes_from.startswith('http')):
379+
if (scheme == 'file' and comes_from and
380+
comes_from.startswith('http')):
381381
raise InstallationError(
382382
'Requirements file %s references URL %s, which is local'
383383
% (comes_from, url))

pip/index.py

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ def _validate_secure_origin(self, logger, location):
228228
addr = ipaddress.ip_address(
229229
origin[1]
230230
if (
231-
isinstance(origin[1], six.text_type)
232-
or origin[1] is None
231+
isinstance(origin[1], six.text_type) or
232+
origin[1] is None
233233
)
234234
else origin[1].decode("utf8")
235235
)
@@ -250,9 +250,9 @@ def _validate_secure_origin(self, logger, location):
250250
continue
251251

252252
# Check to see if the port patches
253-
if (origin[2] != secure_origin[2]
254-
and secure_origin[2] != "*"
255-
and secure_origin[2] is not None):
253+
if (origin[2] != secure_origin[2] and
254+
secure_origin[2] != "*" and
255+
secure_origin[2] is not None):
256256
continue
257257

258258
# If we've gotten here, then this origin matches the current
@@ -369,10 +369,10 @@ def mkurl_pypi_url(url):
369369
req.name.lower()
370370
)
371371
)
372-
if (not found_versions
373-
and not page_versions
374-
and not dependency_versions
375-
and not file_versions):
372+
if (not found_versions and not
373+
page_versions and not
374+
dependency_versions and not
375+
file_versions):
376376
logger.critical(
377377
'Could not find any downloads that satisfy the requirement %s',
378378
req,
@@ -417,8 +417,8 @@ def mkurl_pypi_url(url):
417417

418418
# This is an intentional priority ordering
419419
all_versions = (
420-
file_versions + found_versions + page_versions
421-
+ dependency_versions
420+
file_versions + found_versions + page_versions +
421+
dependency_versions
422422
)
423423

424424
# Filter out anything which doesn't match our specifier
@@ -496,8 +496,8 @@ def mkurl_pypi_url(url):
496496
'Installed version (%s) is most up-to-date (past versions: '
497497
'%s)',
498498
req.satisfied_by.version,
499-
', '.join(str(i.version) for i in applicable_versions[1:])
500-
or "none",
499+
', '.join(str(i.version) for i in applicable_versions[1:]) or
500+
"none",
501501
)
502502
raise BestVersionAlreadyInstalled
503503

@@ -510,8 +510,8 @@ def mkurl_pypi_url(url):
510510

511511
selected_version = applicable_versions[0].location
512512

513-
if (selected_version.verifiable is not None
514-
and not selected_version.verifiable):
513+
if (selected_version.verifiable is not None and not
514+
selected_version.verifiable):
515515
logger.warning(
516516
"%s is potentially insecure and unverifiable.", req.name,
517517
)
@@ -572,8 +572,8 @@ def _get_pages(self, locations, req):
572572
for link in page.rel_links():
573573
normalized = normalize_name(req.name).lower()
574574

575-
if (normalized not in self.allow_external
576-
and not self.allow_all_external):
575+
if (normalized not in self.allow_external and not
576+
self.allow_all_external):
577577
self.need_warn_external = True
578578
logger.debug(
579579
"Not searching %s for files because external "
@@ -582,9 +582,9 @@ def _get_pages(self, locations, req):
582582
)
583583
continue
584584

585-
if (link.trusted is not None
586-
and not link.trusted
587-
and normalized not in self.allow_unverified):
585+
if (link.trusted is not None and not
586+
link.trusted and
587+
normalized not in self.allow_unverified):
588588
logger.debug(
589589
"Not searching %s for urls, it is an "
590590
"untrusted link and cannot produce safe or "
@@ -675,8 +675,8 @@ def _link_package_versions(self, link, search_name):
675675
link
676676
)
677677
return
678-
if (pkg_resources.safe_name(wheel.name).lower()
679-
!= pkg_resources.safe_name(search_name).lower()):
678+
if (pkg_resources.safe_name(wheel.name).lower() !=
679+
pkg_resources.safe_name(search_name).lower()):
680680
logger.debug(
681681
'Skipping link %s; wrong project name (not %s)',
682682
link,
@@ -699,12 +699,12 @@ def _link_package_versions(self, link, search_name):
699699
comes_from = getattr(link, "comes_from", None)
700700
if (
701701
(
702-
not platform.startswith('win')
703-
and not platform.startswith('macosx')
704-
and not platform == 'cli'
705-
)
706-
and comes_from is not None
707-
and urllib_parse.urlparse(
702+
not platform.startswith('win') and not
703+
platform.startswith('macosx') and not
704+
platform == 'cli'
705+
) and
706+
comes_from is not None and
707+
urllib_parse.urlparse(
708708
comes_from.url
709709
).netloc.endswith(PyPI.netloc)):
710710
if not wheel.supported(tags=supported_tags_noarch):
@@ -726,21 +726,21 @@ def _link_package_versions(self, link, search_name):
726726
)
727727
return
728728

729-
if (link.internal is not None
730-
and not link.internal
731-
and not normalize_name(search_name).lower()
732-
in self.allow_external
733-
and not self.allow_all_external):
729+
if (link.internal is not None and not
730+
link.internal and not
731+
normalize_name(search_name).lower()
732+
in self.allow_external and not
733+
self.allow_all_external):
734734
# We have a link that we are sure is external, so we should skip
735735
# it unless we are allowing externals
736736
logger.debug("Skipping %s because it is externally hosted.", link)
737737
self.need_warn_external = True
738738
return
739739

740-
if (link.verifiable is not None
741-
and not link.verifiable
742-
and not (normalize_name(search_name).lower()
743-
in self.allow_unverified)):
740+
if (link.verifiable is not None and not
741+
link.verifiable and not
742+
(normalize_name(search_name).lower()
743+
in self.allow_unverified)):
744744
# We have a link that we are sure we cannot verify its integrity,
745745
# so we should skip it unless we are allowing unsafe installs
746746
# for this requirement.
@@ -856,8 +856,8 @@ def get_page(cls, link, req, skip_archives=True, session=None):
856856
# Tack index.html onto file:// URLs that point to directories
857857
(scheme, netloc, path, params, query, fragment) = \
858858
urllib_parse.urlparse(url)
859-
if (scheme == 'file'
860-
and os.path.isdir(urllib_request.url2pathname(path))):
859+
if (scheme == 'file' and
860+
os.path.isdir(urllib_request.url2pathname(path))):
861861
# add trailing slash if not present so urljoin doesn't trim
862862
# final segment
863863
if not url.endswith('/'):
@@ -978,8 +978,8 @@ def links(self):
978978
# Only api_versions >= 2 have a distinction between
979979
# external and internal links
980980
internal = bool(
981-
anchor.get("rel")
982-
and "internal" in anchor.get("rel").split()
981+
anchor.get("rel") and
982+
"internal" in anchor.get("rel").split()
983983
)
984984

985985
yield Link(url, self, internal=internal)
@@ -1016,9 +1016,9 @@ def scraped_rel_links(self):
10161016
if not href_match:
10171017
continue
10181018
url = (
1019-
href_match.group(1)
1020-
or href_match.group(2)
1021-
or href_match.group(3)
1019+
href_match.group(1) or
1020+
href_match.group(2) or
1021+
href_match.group(3)
10221022
)
10231023
if not url:
10241024
continue

pip/operations/freeze.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ def freeze(
5454
if requirement:
5555
with open(requirement) as req_file:
5656
for line in req_file:
57-
if (not line.strip()
58-
or line.strip().startswith('#')
59-
or (skip_match and skip_match.search(line))
60-
or line.startswith((
57+
if (not line.strip() or
58+
line.strip().startswith('#') or
59+
(skip_match and skip_match.search(line)) or
60+
line.startswith((
6161
'-r', '--requirement',
6262
'-Z', '--always-unzip',
6363
'-f', '--find-links',

pip/req/req_install.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ def from_line(cls, name, comes_from=None, isolated=False):
134134

135135
if is_url(name):
136136
link = Link(name)
137-
elif (os.path.isdir(path)
138-
and (os.path.sep in name or name.startswith('.'))):
137+
elif (os.path.isdir(path) and
138+
(os.path.sep in name or name.startswith('.'))):
139139
if not is_installable_dir(path):
140140
raise InstallationError(
141141
"Directory %r is not installable. File 'setup.py' not "
@@ -323,8 +323,8 @@ def run_egg_info(self):
323323
# NOTE: this self.name check only works when installing from a
324324
# specifier (not archive path/urls)
325325
# TODO: take this out later
326-
if (self.name == 'distribute'
327-
and not os.path.isdir(
326+
if (self.name == 'distribute' and not
327+
os.path.isdir(
328328
os.path.join(self.source_dir, 'setuptools'))):
329329
rmtree(os.path.join(self.source_dir, 'distribute.egg-info'))
330330

@@ -431,8 +431,8 @@ def egg_info_path(self, filename):
431431
if (
432432
os.path.exists(
433433
os.path.join(root, dir, 'bin', 'python')
434-
)
435-
or os.path.exists(
434+
) or
435+
os.path.exists(
436436
os.path.join(
437437
root, dir, 'Scripts', 'Python.exe'
438438
)
@@ -457,8 +457,8 @@ def egg_info_path(self, filename):
457457
# an extracted tarball for testing purposes.
458458
if len(filenames) > 1:
459459
filenames.sort(
460-
key=lambda x: x.count(os.path.sep)
461-
+ (os.path.altsep and x.count(os.path.altsep) or 0)
460+
key=lambda x: x.count(os.path.sep) +
461+
(os.path.altsep and x.count(os.path.altsep) or 0)
462462
)
463463
self._egg_info_path = os.path.join(base, filenames[0])
464464
return os.path.join(self._egg_info_path, filename)
@@ -878,10 +878,10 @@ def install_editable(self, install_options, global_options=()):
878878
"import setuptools, tokenize; __file__=%r; exec(compile("
879879
"getattr(tokenize, 'open', open)(__file__).read().replace"
880880
"('\\r\\n', '\\n'), __file__, 'exec'))" % self.setup_py
881-
]
882-
+ list(global_options)
883-
+ ['develop', '--no-deps']
884-
+ list(install_options),
881+
] +
882+
list(global_options) +
883+
['develop', '--no-deps'] +
884+
list(install_options),
885885

886886
cwd=cwd, filter_stdout=self._filter_install,
887887
show_stdout=False)
@@ -924,9 +924,9 @@ def check_if_exists(self):
924924
# then this check has already run before. we don't want it to
925925
# run again, and return False, since it would block the uninstall
926926
# TODO: remove this later
927-
if (self.req.project_name == 'setuptools'
928-
and self.conflicts_with
929-
and self.conflicts_with.project_name == 'distribute'):
927+
if (self.req.project_name == 'setuptools' and
928+
self.conflicts_with and
929+
self.conflicts_with.project_name == 'distribute'):
930930
return True
931931
else:
932932
self.satisfied_by = pkg_resources.get_distribution(self.req)
@@ -939,8 +939,8 @@ def check_if_exists(self):
939939
if self.use_user_site:
940940
if dist_in_usersite(existing_dist):
941941
self.conflicts_with = existing_dist
942-
elif (running_under_virtualenv()
943-
and dist_in_site_packages(existing_dist)):
942+
elif (running_under_virtualenv() and
943+
dist_in_site_packages(existing_dist)):
944944
raise InstallationError(
945945
"Will not install to the user site because it will "
946946
"lack sys.path precedence to %s in %s" %

0 commit comments

Comments
 (0)