Преглед на файлове

Fix pylint warning len-as-conditional

Bahtiar `kalkin-` Gadimov преди 7 години
родител
ревизия
eb217e0d27
променени са 6 файла, в които са добавени 7 реда и са изтрити 7 реда
  1. 1 1
      qubes/app.py
  2. 1 1
      qubes/devices.py
  3. 1 1
      qubes/tarwriter.py
  4. 2 2
      qubes/tools/__init__.py
  5. 1 1
      qubes/tools/qvm_check.py
  6. 1 1
      qubes/tools/qvm_pool.py

+ 1 - 1
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:

+ 1 - 1
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
 

+ 1 - 1
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

+ 2 - 2
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))

+ 1 - 1
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))

+ 1 - 1
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