This is an automated email from the ASF dual-hosted git repository.

dahn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/main by this push:
     new b69cc0272d4 pre-commit: enable Python Flake8 rule `E713` (#9016)
b69cc0272d4 is described below

commit b69cc0272d48f0aea7353627d760c27c284dad84
Author: John Bampton <[email protected]>
AuthorDate: Mon Jul 8 17:00:18 2024 +1000

    pre-commit: enable Python Flake8 rule `E713` (#9016)
    
    Co-authored-by: Vishesh <[email protected]>
---
 .github/linters/.flake8                                        |  3 ++-
 .../ovm/src/main/scripts/vm/hypervisor/ovm/OvmCommonModule.py  |  4 ++--
 python/lib/cloud_utils.py                                      |  4 ++--
 scripts/network/ping/baremetal_user_data.py                    |  2 +-
 scripts/vm/hypervisor/xenserver/perfmon.py                     |  2 +-
 scripts/vm/network/security_group.py                           |  2 +-
 scripts/vm/network/vnet/ovstunnel.py                           |  2 +-
 test/integration/component/test_tags.py                        |  2 +-
 test/integration/smoke/test_scale_vm.py                        | 10 +++++-----
 tools/marvin/marvin/cloudstackTestCase.py                      |  2 +-
 10 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/.github/linters/.flake8 b/.github/linters/.flake8
index f250719ca19..c513b0e3c4b 100644
--- a/.github/linters/.flake8
+++ b/.github/linters/.flake8
@@ -24,6 +24,7 @@
 # E242 Tab after ','
 # E273 Tab after keyword
 # E274 Tab before keyword
+# E713 Test for membership should be 'not in'
 # E742 Do not define classes named 'I', 'O', or 'l'
 # E743 Do not define functions named 'I', 'O', or 'l'
 # E901 SyntaxError or IndentationError
@@ -37,4 +38,4 @@
 exclude =
     .git,
     venv
-select = 
E112,E113,E133,E223,E224,E227,E242,E273,E274,E742,E743,E901,E902,W291,W292,W293,W391
+select = 
E112,E113,E133,E223,E224,E227,E242,E273,E274,E713,E742,E743,E901,E902,W291,W292,W293,W391
diff --git 
a/plugins/hypervisors/ovm/src/main/scripts/vm/hypervisor/ovm/OvmCommonModule.py 
b/plugins/hypervisors/ovm/src/main/scripts/vm/hypervisor/ovm/OvmCommonModule.py
index 8cd715dd3b3..eb50a2e0b1c 100755
--- 
a/plugins/hypervisors/ovm/src/main/scripts/vm/hypervisor/ovm/OvmCommonModule.py
+++ 
b/plugins/hypervisors/ovm/src/main/scripts/vm/hypervisor/ovm/OvmCommonModule.py
@@ -75,7 +75,7 @@ def asciiLoads(jStr):
 
 def exceptionIfNoSuccess(str, errMsg=None):
     if not errMsg: errMsg = str
-    if not "success" in str: raise Exception("%s (%s)"%(errMsg, str))
+    if "success" not in str: raise Exception("%s (%s)"%(errMsg, str))
 
 def successToMap(str, sep=';'):
     if not str.startswith("success"): raise Exception(str)
@@ -135,7 +135,7 @@ def getDomId(vm_name):
     return execute("xm list | grep " + vm_name + " | awk '{print $2}'").strip()
 
 def raiseExceptionIfFail(res):
-    if not "success" in res and not "SUCC" in res: raise Exception(res)
+    if "success" not in res and "SUCC" not in res: raise Exception(res)
 
 def ipToHeartBeatFileName(ip):
     return ip.replace('.', '_') + "_HEARTBEAT"
diff --git a/python/lib/cloud_utils.py b/python/lib/cloud_utils.py
index d424bf1f023..3d452ee48d6 100644
--- a/python/lib/cloud_utils.py
+++ b/python/lib/cloud_utils.py
@@ -433,7 +433,7 @@ def setup_agent_config(configfile, host, zone, pod, 
cluster, guid, pubNic, prvNi
        if guid != None:
                confopts['guid'] = guid
        else:
-               if not "guid" in confopts:
+               if "guid" not in confopts:
                        stderr("Generating GUID for this Agent")
                        confopts['guid'] = uuidgen().stdout.strip()
 
@@ -491,7 +491,7 @@ def setup_consoleproxy_config(configfile, host, zone, pod):
        confopts = dict([ m.split("=",1) for m in lines if "=" in m and not 
m.startswith("#") ])
        confposes = dict([ (m.split("=",1)[0],n) for n,m in enumerate(lines) if 
"=" in m and not m.startswith("#") ])
 
-       if not "guid" in confopts:
+       if "guid" not in confopts:
                stderr("Generating GUID for this Console Proxy")
                confopts['guid'] = uuidgen().stdout.strip()
 
diff --git a/scripts/network/ping/baremetal_user_data.py 
b/scripts/network/ping/baremetal_user_data.py
index 5a189353467..02fe845392c 100755
--- a/scripts/network/ping/baremetal_user_data.py
+++ b/scripts/network/ping/baremetal_user_data.py
@@ -38,7 +38,7 @@ def writeIfNotHere(fileName, texts):
     texts = [ "%s\n" % t for t in texts ]
     need = False
     for t in texts:
-        if not t in entries:
+        if t not in entries:
             entries.append(t)
             need = True
 
diff --git a/scripts/vm/hypervisor/xenserver/perfmon.py 
b/scripts/vm/hypervisor/xenserver/perfmon.py
index c310cdcf356..59c1ac3b367 100755
--- a/scripts/vm/hypervisor/xenserver/perfmon.py
+++ b/scripts/vm/hypervisor/xenserver/perfmon.py
@@ -179,7 +179,7 @@ class RRDUpdates:
         (cf, vm_or_host, uuid, param) = col_meta_data.split(':')
         if vm_or_host == 'vm':
             # Create a report for this VM if it doesn't exist
-            if not uuid in self.vm_reports:
+            if uuid not in self.vm_reports:
                 self.vm_reports[uuid] = VMReport(uuid)
                 # Update the VMReport with the col data and meta data
             vm_report = self.vm_reports[uuid]
diff --git a/scripts/vm/network/security_group.py 
b/scripts/vm/network/security_group.py
index 8d72557fb4f..37a1a94fe7f 100755
--- a/scripts/vm/network/security_group.py
+++ b/scripts/vm/network/security_group.py
@@ -1102,7 +1102,7 @@ def add_network_rules(vm_name, vm_id, vm_ip, vm_ip6, 
signature, seqno, vmMac, ru
 
         changes = check_rule_log_for_vm(vmName, vm_id, vm_ip, domId, 
signature, seqno)
 
-        if not 1 in changes:
+        if 1 not in changes:
             logging.debug("Rules already programmed for vm " + vm_name)
             return True
 
diff --git a/scripts/vm/network/vnet/ovstunnel.py 
b/scripts/vm/network/vnet/ovstunnel.py
index 304e4920895..a39b6b18ecc 100755
--- a/scripts/vm/network/vnet/ovstunnel.py
+++ b/scripts/vm/network/vnet/ovstunnel.py
@@ -202,7 +202,7 @@ def create_tunnel(bridge, remote_ip, key, src_host, 
dst_host):
         key_validation = lib.do_cmd(verify_interface_key)
         ip_validation = lib.do_cmd(verify_interface_ip)
 
-        if not key in str(key_validation) or not remote_ip in 
str(ip_validation):
+        if key not in str(key_validation) or remote_ip not in 
str(ip_validation):
             logging.debug("WARNING: Unexpected output while verifying " +
                           "interface %s on bridge %s" % (name, bridge))
 #            return "FAILURE:VERIFY_INTERFACE_FAILED"
diff --git a/test/integration/component/test_tags.py 
b/test/integration/component/test_tags.py
index 2141384eaf7..6ee5d3c6ea9 100644
--- a/test/integration/component/test_tags.py
+++ b/test/integration/component/test_tags.py
@@ -2426,7 +2426,7 @@ class TestResourceTags(cloudstackTestCase):
         hosts.pop(0)
         host_ids = [host.id for host in hosts]
         for id in host_ids:
-            if not id in host_ids_for_migration:
+            if id not in host_ids_for_migration:
                 self.fail("Not all hosts are available for vm migration")
         return
 
diff --git a/test/integration/smoke/test_scale_vm.py 
b/test/integration/smoke/test_scale_vm.py
index 7f8b65b8465..c2ae85df3b2 100644
--- a/test/integration/smoke/test_scale_vm.py
+++ b/test/integration/smoke/test_scale_vm.py
@@ -221,7 +221,7 @@ class TestScaleVm(cloudstackTestCase):
             result = str(
                 sshClient.execute("service vmware-tools status")).lower()
             self.debug("and result is: %s" % result)
-            if not "running" in result:
+            if "running" not in result:
                 self.skipTest("Skipping scale VM operation because\
                     VMware tools are not installed on the VM")
         res = None
@@ -355,7 +355,7 @@ class TestScaleVm(cloudstackTestCase):
             result = str(
                 sshClient.execute("service vmware-tools status")).lower()
             self.debug("and result is: %s" % result)
-            if not "running" in result:
+            if "running" not in result:
                 self.skipTest("Skipping scale VM operation because\
                     VMware tools are not installed on the VM")
 
@@ -464,7 +464,7 @@ class TestScaleVm(cloudstackTestCase):
             result = str(
                 sshClient.execute("service vmware-tools status")).lower()
             self.debug("and result is: %s" % result)
-            if not "running" in result:
+            if "running" not in result:
                 self.skipTest("Skipping scale VM operation because\
                     VMware tools are not installed on the VM")
 
@@ -555,7 +555,7 @@ class TestScaleVm(cloudstackTestCase):
             result = str(
                 sshClient.execute("service vmware-tools status")).lower()
             self.debug("and result is: %s" % result)
-            if not "running" in result:
+            if "running" not in result:
                 self.skipTest("Skipping scale VM operation because\
                     VMware tools are not installed on the VM")
         res = None
@@ -700,7 +700,7 @@ class TestScaleVm(cloudstackTestCase):
             result = str(
                 sshClient.execute("service vmware-tools status")).lower()
             self.debug("and result is: %s" % result)
-            if not "running" in result:
+            if "running" not in result:
                 self.skipTest("Skipping scale VM operation because\
                     VMware tools are not installed on the VM")
         res = None
diff --git a/tools/marvin/marvin/cloudstackTestCase.py 
b/tools/marvin/marvin/cloudstackTestCase.py
index 1164cd9f0f8..297031611e9 100644
--- a/tools/marvin/marvin/cloudstackTestCase.py
+++ b/tools/marvin/marvin/cloudstackTestCase.py
@@ -183,7 +183,7 @@ class cloudstackTestCase(unittest.case.TestCase):
             sshClient.execute("service httpd start")
             time.sleep(5)
             ssh_response = str(sshClient.execute("service httpd 
status")).lower()
-        if not "running" in ssh_response:
+        if "running" not in ssh_response:
             raise Exception("Failed to start httpd service")
         self.debug("Setup webserver using apache")
 

Reply via email to