Skip to content

Commit

Permalink
pre-commit: enable Python Flake8 rule E713 (#9016)
Browse files Browse the repository at this point in the history
Co-authored-by: Vishesh <vishesh92@gmail.com>
  • Loading branch information
jbampton and vishesh92 authored Jul 8, 2024
1 parent 1144f52 commit b69cc02
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .github/linters/.flake8
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions python/lib/cloud_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion scripts/network/ping/baremetal_user_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion scripts/vm/hypervisor/xenserver/perfmon.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def __handle_col(self, col):
(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]
Expand Down
2 changes: 1 addition & 1 deletion scripts/vm/network/security_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion scripts/vm/network/vnet/ovstunnel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion test/integration/component/test_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -2426,7 +2426,7 @@ def test_23_list_untagged_host_for_vm_migration(self):
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

Expand Down
10 changes: 5 additions & 5 deletions test/integration/smoke/test_scale_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def test_01_scale_vm(self):
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
Expand Down Expand Up @@ -355,7 +355,7 @@ def test_02_scale_vm_negative_offering_disable_scaling(self):
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")

Expand Down Expand Up @@ -464,7 +464,7 @@ def test_03_scale_vm_negative_vm_disable_scaling(self):
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")

Expand Down Expand Up @@ -555,7 +555,7 @@ def test_04_scale_vm_with_user_account(self):
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
Expand Down Expand Up @@ -700,7 +700,7 @@ def test_05_scale_vm_dont_allow_disk_offering_change(self):
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
Expand Down
2 changes: 1 addition & 1 deletion tools/marvin/marvin/cloudstackTestCase.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def setup_apache(self, sshClient):
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")

Expand Down

0 comments on commit b69cc02

Please sign in to comment.