From eb217e0d274e8e5553be4b3ac978a18e77aa890e Mon Sep 17 00:00:00 2001 From: Bahtiar `kalkin-` Gadimov Date: Sat, 15 Apr 2017 20:03:38 +0200 Subject: [PATCH] Fix pylint warning len-as-conditional --- qubes/app.py | 2 +- qubes/devices.py | 2 +- qubes/tarwriter.py | 2 +- qubes/tools/__init__.py | 4 ++-- qubes/tools/qvm_check.py | 2 +- qubes/tools/qvm_pool.py | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/qubes/app.py b/qubes/app.py index 00c7c126..2709ccc1 100644 --- a/qubes/app.py +++ b/qubes/app.py @@ -480,7 +480,7 @@ class VMCollection(object): # if not self[netvm_qid].is_netvm(): # return set([]) - while len(new_vms) > 0: + while new_vms: cur_vm = new_vms.pop() for vm in cur_vm.connected_vms: if vm in dependent_vms: diff --git a/qubes/devices.py b/qubes/devices.py index 1fce57f4..27d4995d 100644 --- a/qubes/devices.py +++ b/qubes/devices.py @@ -234,7 +234,7 @@ class DeviceCollection(object): DeviceAssignment(backend_domain=dev.backend_domain, ident=dev.ident, options=options, frontend_domain=self._vm)) - if persistent is not False and len(result) == 0: + if persistent is not False and not result: result.extend(self._set) return result diff --git a/qubes/tarwriter.py b/qubes/tarwriter.py index 35bef30d..0c7e0d49 100644 --- a/qubes/tarwriter.py +++ b/qubes/tarwriter.py @@ -38,7 +38,7 @@ class TarSparseInfo(tarfile.TarInfo): @property def realsize(self): - if len(self.sparsemap): + if self.sparsemap: return self.sparsemap[-1][0] + self.sparsemap[-1][1] else: return self.size diff --git a/qubes/tools/__init__.py b/qubes/tools/__init__.py index f17abde3..4f423f47 100644 --- a/qubes/tools/__init__.py +++ b/qubes/tools/__init__.py @@ -257,8 +257,8 @@ class VolumeAction(QubesAction): try: pool = app.pools[pool_name] volume = [v for v in pool.volumes if v.vid == vid] - assert volume > 1, 'Duplicate vids in pool %s' % pool_name - if len(volume) == 0: + assert len(volume) == 1, 'Duplicate vids in pool %s' % pool_name + if not volume: parser.error_runtime( 'no volume with id {!r} pool: {!r}'.format(vid, pool_name)) diff --git a/qubes/tools/qvm_check.py b/qubes/tools/qvm_check.py index 0a911528..bf6e97fc 100644 --- a/qubes/tools/qvm_check.py +++ b/qubes/tools/qvm_check.py @@ -38,7 +38,7 @@ parser.add_argument("--template", action="store_true", dest="template", def print_msg(domains, what_single, what_plural): - if len(domains) == 0: + if not domains: print("None of given VM {!s}".format(what_single)) elif len(domains) == 1: print("VM {!s} {!s}".format(domains[0], what_single)) diff --git a/qubes/tools/qvm_pool.py b/qubes/tools/qvm_pool.py index 2c141988..4c028b8a 100644 --- a/qubes/tools/qvm_pool.py +++ b/qubes/tools/qvm_pool.py @@ -84,7 +84,7 @@ def list_pools(app): ''' Prints out all known pools and their drivers ''' result = [('NAME', 'DRIVER')] for pool in app.pools.values(): - if len(pool.volumes) == 0 and issubclass( + if not pool.volumes and issubclass( pool.__class__, qubes.storage.domain.DomainPool): # skip empty DomainPools continue