1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00

Misc syntax updates

This commit is contained in:
Donald Stufft 2017-03-18 14:26:30 -04:00
parent a504ebdbcc
commit 0708de5b34
8 changed files with 15 additions and 15 deletions

View file

@ -135,7 +135,7 @@ class DownloadCommand(RequirementCommand):
options.abi,
options.implementation,
])
binary_only = FormatControl(set(), set([':all:']))
binary_only = FormatControl(set(), {':all:'})
if dist_restriction_set and options.format_control != binary_only:
raise CommandError(
"--only-binary=:all: must be set and --no-binary must not "

View file

@ -9,7 +9,7 @@ from pip.operations.freeze import freeze
from pip.wheel import WheelCache
DEV_PKGS = ('pip', 'setuptools', 'distribute', 'wheel')
DEV_PKGS = {'pip', 'setuptools', 'distribute', 'wheel'}
class FreezeCommand(Command):

View file

@ -47,7 +47,7 @@ class Configuration(object):
if files:
self._configparser.read(files)
for section in ('global', section):
for section in {'global', section}:
self._config.update(
self._normalize_keys(self._get_config_section(section))
)

View file

@ -833,7 +833,7 @@ class HTMLPage(object):
def _get_content_type(url, session):
"""Get the Content-Type of the given url, using a HEAD request"""
scheme, netloc, path, query, fragment = urllib_parse.urlsplit(url)
if scheme not in ('http', 'https'):
if scheme not in {'http', 'https'}:
# FIXME: some warning or something?
# assertion error?
return ''
@ -1067,7 +1067,7 @@ def fmt_ctl_handle_mutual_exclude(value, target, other):
def fmt_ctl_formats(fmt_ctl, canonical_name):
result = set(["binary", "source"])
result = {"binary", "source"}
if canonical_name in fmt_ctl.only_binary:
result.discard('source')
elif canonical_name in fmt_ctl.no_binary:

View file

@ -22,7 +22,7 @@ def get_missing_reqs(dist, installed_dists):
`installed_dists`.
"""
installed_names = set(d.project_name.lower() for d in installed_dists)
installed_names = {d.project_name.lower() for d in installed_dists}
missing_requirements = set()
for requirement in dist.requires():

View file

@ -22,7 +22,7 @@ def get_config_var(var):
try:
return sysconfig.get_config_var(var)
except IOError as e: # Issue #1074
warnings.warn("{0}".format(e), RuntimeWarning)
warnings.warn("{}".format(e), RuntimeWarning)
return None
@ -62,7 +62,7 @@ def get_impl_tag():
"""
Returns the Tag for this specific implementation.
"""
return "{0}{1}".format(get_abbr_impl(), get_impl_ver())
return "{}{}".format(get_abbr_impl(), get_impl_ver())
def get_flag(var, fallback, expected=True, warn=True):
@ -82,7 +82,7 @@ def get_abi_tag():
(CPython 2, PyPy)."""
soabi = get_config_var('SOABI')
impl = get_abbr_impl()
if not soabi and impl in ('cp', 'pp') and hasattr(sys, 'maxunicode'):
if not soabi and impl in {'cp', 'pp'} and hasattr(sys, 'maxunicode'):
d = ''
m = ''
u = ''
@ -129,7 +129,7 @@ def get_platform():
elif machine == "ppc64" and _is_running_32bit():
machine = "ppc"
return 'macosx_{0}_{1}_{2}'.format(split_ver[0], split_ver[1], machine)
return 'macosx_{}_{}_{}'.format(split_ver[0], split_ver[1], machine)
# XXX remove distutils dependency
result = distutils.util.get_platform().replace('.', '_').replace('-', '_')
@ -143,7 +143,7 @@ def get_platform():
def is_manylinux1_compatible():
# Only Linux, and only x86-64 / i686
if get_platform() not in ("linux_x86_64", "linux_i686"):
if get_platform() not in {"linux_x86_64", "linux_i686"}:
return False
# Check for presence of _manylinux module
@ -269,7 +269,7 @@ def get_supported(versions=None, noarch=False, platform=None,
match = _osx_arch_pat.match(arch)
if match:
name, major, minor, actual_arch = match.groups()
tpl = '{0}_{1}_%i_%s'.format(name, major)
tpl = '{}_{}_%i_%s'.format(name, major)
arches = []
for m in reversed(range(int(minor) + 1)):
for a in get_darwin_arches(int(major), m, actual_arch):
@ -290,7 +290,7 @@ def get_supported(versions=None, noarch=False, platform=None,
# abi3 modules compatible with older version of Python
for version in versions[1:]:
# abi3 was introduced in Python 3.2
if version in ('31', '30'):
if version in {'31', '30'}:
break
for abi in abi3s: # empty set if not Python 3
for arch in arches:

View file

@ -320,7 +320,7 @@ class InstallRequirement(object):
"""
specifiers = self.specifier
return (len(specifiers) == 1 and
next(iter(specifiers)).operator in ('==', '==='))
next(iter(specifiers)).operator in {'==', '==='})
def from_path(self):
if self.req is None:

View file

@ -126,7 +126,7 @@ def cached_wheel(cache_dir, link, format_control, package_name):
try:
wheel_names = os.listdir(root)
except OSError as e:
if e.errno in (errno.ENOENT, errno.ENOTDIR):
if e.errno in {errno.ENOENT, errno.ENOTDIR}:
return link
raise
candidates = []