pre-commit: enable Python flake8 rule E271 (#9358)

This commit is contained in:
John Bampton 2024-07-09 18:17:53 +10:00 committed by GitHub
parent a1d8bab43f
commit c6d3f6e623
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 18 additions and 17 deletions

View File

@ -22,6 +22,7 @@
# E224 Tab after operator
# E227 Missing whitespace around bitwise or shift operator
# E242 Tab after ','
# E271 Multiple spaces after keyword
# E273 Tab after keyword
# E274 Tab before keyword
# E713 Test for membership should be 'not in'
@ -38,4 +39,4 @@
exclude =
.git,
venv
select = E112,E113,E133,E223,E224,E227,E242,E273,E274,E713,E742,E743,E901,E902,W291,W292,W293,W391
select = E112,E113,E133,E223,E224,E227,E242,E271,E273,E274,E713,E742,E743,E901,E902,W291,W292,W293,W391

View File

@ -375,7 +375,7 @@ def list_zonespods(host):
x = [ (zonename,podname)
for pod in dom.childNodes[0].childNodes
for podname in [ x.childNodes[0].wholeText for x in pod.childNodes if x.tagName == "name" ]
for zonename in [ x.childNodes[0].wholeText for x in pod.childNodes if x.tagName == "zonename" ]
for zonename in [ x.childNodes[0].wholeText for x in pod.childNodes if x.tagName == "zonename" ]
]
return x

View File

@ -114,7 +114,7 @@ class sysConfigAgent(sysConfig):
pass
if size != -1 and size < (30 * 1024 * 1024):
raise CloudRuntimeException("Need at least 30G free disk space under /var/lib/libvirt/images")
raise CloudRuntimeException("Need at least 30G free disk space under /var/lib/libvirt/images")
#check memory
mem = -1
@ -124,7 +124,7 @@ class sysConfigAgent(sysConfig):
pass
if mem != -1 and mem < 1:
raise CloudRuntimeException("Need at least 1G memory")
raise CloudRuntimeException("Need at least 1G memory")
if os.geteuid() != 0:

View File

@ -47,11 +47,11 @@ class bash:
alarm(0)
except Alarm:
os.kill(self.process.pid, SIGKILL)
raise CloudRuntimeException("Timeout during command execution")
raise CloudRuntimeException("Timeout during command execution")
self.success = self.process.returncode == 0
except:
raise CloudRuntimeException(formatExceptionInfo())
raise CloudRuntimeException(formatExceptionInfo())
if not self.success:
logging.debug("Failed to execute:" + self.getErrMsg())

View File

@ -67,7 +67,7 @@ def getServicesConfig( config_file_path = "/etc/monitor.conf" ):
process_dict[section][name] = value
printd (" %s = %r" % (name, value))
return process_dict
return process_dict
def printd (msg):
"""

View File

@ -1190,7 +1190,7 @@ class TestStorageLiveMigrationVmware(cloudstackTestCase):
a) Create VM snapshots to check data integrity - @method used : VmSnapshotToCheckDataIntegrity(self, vm)
c) Check for VM accessibility by sshing to the VM - @method used : check_for_vm_access_by_ssh_using_nat(self, virtual_machine_1)
"""
if not self.zone.localstorageenabled:
if not self.zone.localstorageenabled:
raise self.skipTest("The setup doesn't have local storage enabled")
scope = first_value
ostype = second_value

View File

@ -571,7 +571,7 @@ class TestXDCCPInterop(cloudstackTestCase):
id=self.volume.id
)
if list_volume_response1[0].virtualmachineid is None:
if list_volume_response1[0].virtualmachineid is None:
self.skipTest("Check if volume is attached to the VM before detach")
self.virtual_machine.detach_volume(self.user_api_client, self.volume)
@ -618,7 +618,7 @@ class TestXDCCPInterop(cloudstackTestCase):
id=self.volume.id
)
if list_volume_response1[0].virtualmachineid is not None:
if list_volume_response1[0].virtualmachineid is not None:
self.skipTest("Check if volume is detached before deleting")
cmd = deleteVolume.deleteVolumeCmd()

View File

@ -647,7 +647,7 @@ class TestResizeVolume(cloudstackTestCase):
self.assertEqual(virtualmachine_snapshot.id,
virtulmachine_snapshot_list[0].id,
"Virtual Machine Snapshot id do not match")
except Exception as e:
except Exception as e:
raise Exception("Issue CLOUDSTACK-10080: Exception while performing"
" vmsnapshot: %s" % e)
else:

View File

@ -766,7 +766,7 @@ class TestKubernetesCluster(cloudstackTestCase):
self.verifyKubernetesCluster(cluster, cluster.name, None, size, control_nodes)
self.debug("Existing Kubernetes cluster available with name %s" % cluster.name)
return cluster
except AssertionError as error:
except AssertionError as error:
self.debug("Existing cluster failed verification due to %s, need to deploy a new one" % error)
self.deleteKubernetesClusterAndVerify(cluster.id, False, True)

View File

@ -920,6 +920,6 @@ class TestPrivateGwACL(cloudstackTestCase):
(select id from physical_network where uuid='%s');" % physical_network.id
)
for traffic_type in traffic_type_list:
if "Guest" in str(traffic_type[0]):
if "Guest" in str(traffic_type[0]):
return physical_network
return None

View File

@ -683,7 +683,7 @@ class TestPrivateGwACLOvsGRE(cloudstackTestCase):
(select id from physical_network where uuid='%s');" % physical_network.id
)
for traffic_type in traffic_type_list:
if "Guest" in str(traffic_type[0]):
if "Guest" in str(traffic_type[0]):
return physical_network
return None

View File

@ -88,7 +88,7 @@ class CloudstackAclException():
@staticmethod
def verifyErrorCodeinException(e,errorCode):
errorString = " errorCode: " + errorCode
if errorString in str(e):
if errorString in str(e):
return True
else:
return False

View File

@ -47,7 +47,7 @@ class DbConnection(object):
with contextlib.closing(conn.cursor(buffered=True)) as cursor:
cursor.execute(sql, params)
try:
if sql.lower().startswith('select') and cursor.rowcount > 0:
if sql.lower().startswith('select') and cursor.rowcount > 0:
# we have more than just the row count/success
resultRow = cursor.fetchall()
except errors.InterfaceError:

View File

@ -93,7 +93,7 @@ class NCC:
elif isolation_policy.lower() == "dedicated":
srv_pkg = self.createServicePackageDedicated(name, tnt_group_id, dv_group_id, isolation_policy )
else:
raise Exception("NS device must be either in shared or dedicated mode")
raise Exception("NS device must be either in shared or dedicated mode")
if srv_pkg.status_code != 201:
raise Exception("Error: %s" % self.__lastError)
dev_add_res =self.addDevicetoServicePackage(dv_group_id, device_ip)