pylint len-as-condition

This commit is contained in:
Carlos Meza 2018-02-18 20:41:40 -08:00
parent 98975cac7b
commit c068ba07ab
9 changed files with 11 additions and 11 deletions

View file

@ -21,7 +21,7 @@ class GPTPartitionMap(AbstractPartitionMap):
# Returns the last partition unless there is none
def last_partition():
return self.partitions[-1] if len(self.partitions) > 0 else None
return self.partitions[-1] if self.partitions else None
if bootloader == 'grub':
# If we are using the grub bootloader we need to create an unformatted partition

View file

@ -23,7 +23,7 @@ class MSDOSPartitionMap(AbstractPartitionMap):
# Returns the last partition unless there is none
def last_partition():
return self.partitions[-1] if len(self.partitions) > 0 else None
return self.partitions[-1] if self.partitions else None
# The boot and swap partitions are optional
if 'boot' in data:

View file

@ -82,11 +82,11 @@ class Source(object):
:rtype: str
"""
options = ''
if len(self.options) > 0:
if self.options:
options = ' [{options}]'.format(options=' '.join(self.options))
components = ''
if len(self.components) > 0:
if self.components:
components = ' {components}'.format(components=' '.join(self.components))
return ('{type}{options} {uri} {distribution}{components}'

View file

@ -34,7 +34,7 @@ class FSMProxy(object):
fn = getattr(fsm, event)
def proxy(*args, **kwargs):
if len(args) > 0:
if args:
raise FSMProxyError('FSMProxy event listeners only accept named arguments.')
fn(**kwargs)
return proxy

View file

@ -34,9 +34,9 @@ def get_bootstrap_args(info):
else:
from bootstrapvz.common.exceptions import ManifestError
raise ManifestError('force-check-gpg is only support in Stretch and newer releases')
if len(info.include_packages) > 0:
if info.include_packages:
options.append('--include=' + ','.join(info.include_packages))
if len(info.exclude_packages) > 0:
if info.exclude_packages:
options.append('--exclude=' + ','.join(info.exclude_packages))
mirror = info.manifest.bootstrapper.get('mirror', info.apt_mirror)
arguments = [info.manifest.system['release'], info.root, mirror]

View file

@ -211,7 +211,7 @@ class WriteGrubConfig(Task):
elif isinstance(value, bool):
grub_config_contents += '{}="{}"\n'.format(key, str(value).lower())
elif isinstance(value, list):
if len(value) > 0:
if value:
args_list = ' '.join(map(str, value))
grub_config_contents += '{}="{}"\n'.format(key, args_list)
elif value is not None:

View file

@ -30,6 +30,6 @@ class CheckExternalCommands(Task):
'it is located in the package `{package}\'.'
.format(command=command, package=package))
missing_packages.append(msg)
if len(missing_packages) > 0:
if missing_packages:
msg = '\n'.join(missing_packages)
raise TaskError(msg)

View file

@ -30,7 +30,7 @@ def resolve_tasks(taskset, manifest):
options = manifest.plugins['cloud_init']
if 'username' in options:
taskset.add(tasks.SetUsername)
if 'groups' in options and len(options['groups']):
if 'groups' in options and options['groups']:
taskset.add(tasks.SetGroups)
if 'enable_modules' in options:
taskset.add(tasks.EnableModules)

View file

@ -23,5 +23,5 @@ def resolve_tasks(taskset, manifest):
taskset.add(tasks.AddDockerBinary)
taskset.add(tasks.AddDockerInit)
taskset.add(tasks.EnableMemoryCgroup)
if len(manifest.plugins['docker_daemon'].get('pull_images', [])) > 0:
if manifest.plugins['docker_daemon'].get('pull_images', []):
taskset.add(tasks.PullDockerImages)