Skip to content

Commit

Permalink
mypy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SRIKKANTH committed Jan 1, 2025
1 parent e5bd41e commit 25d54d0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lisa/sut_orchestrator/hyperv/get_assignable_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def __get_pnp_device_property(self, device_id: str, property_name: str) -> str:
sudo=True,
force_run=True,
)
return output.strip()
return str(output.strip())

def __load_pnp_allocated_resources(self) -> List[Dict[str, str]]:
# Command output result (just 2 device properties)
Expand Down
18 changes: 10 additions & 8 deletions lisa/tools/hyperv.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def exists_vm(self, name: str) -> bool:
force_run=True,
)

return output.strip() != ""
return bool(output.strip() != "")

def delete_vm_async(self, name: str) -> Optional[Process]:
# check if vm is present
Expand Down Expand Up @@ -219,7 +219,7 @@ def exists_switch(self, name: str) -> bool:
fail_on_error=False,
force_run=True,
)
return output.strip() != ""
return bool(output.strip() != "")

def delete_switch(self, name: str) -> None:
if self.exists_switch(name):
Expand Down Expand Up @@ -251,7 +251,7 @@ def exists_nat(self, name: str) -> bool:
fail_on_error=False,
force_run=True,
)
return output.strip() != ""
return bool(output.strip() != "")

def delete_nat(self, name: str) -> None:
if self.exists_nat(name):
Expand Down Expand Up @@ -317,7 +317,7 @@ def get_ip_address(self, name: str) -> str:
if not ip_address:
raise LisaException(f"Could not find IP address for VM {name}")

return ip_address
return str(ip_address)

def exist_port_forwarding(
self,
Expand All @@ -328,7 +328,7 @@ def exist_port_forwarding(
fail_on_error=False,
force_run=True,
)
return output.strip() != ""
return bool(output.strip() != "")

def delete_port_forwarding(self, nat_name: str) -> None:
if self.exist_port_forwarding(nat_name):
Expand Down Expand Up @@ -359,7 +359,7 @@ def exists_virtual_disk(self, name: str) -> bool:
fail_on_error=False,
force_run=True,
)
return output.strip() != ""
return bool(output.strip() != "")

def delete_virtual_disk(self, name: str) -> None:
if self.exists_virtual_disk(name):
Expand Down Expand Up @@ -417,6 +417,8 @@ def _run_hyperv_cmdlet(
pwsh = self.node.tools[PowerShell]
if not extra_args:
extra_args = {}
return pwsh.run_cmdlet(
f"{cmd} {args} {extra_args.get(cmd.lower(), '')}", force_run=force_run
return str(
pwsh.run_cmdlet(
f"{cmd} {args} {extra_args.get(cmd.lower(), '')}", force_run=force_run
)
)
6 changes: 3 additions & 3 deletions lisa/tools/ls.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ def is_file(self, path: PurePath, sudo: bool = False) -> bool:
sudo=sudo,
)

return output.strip() == "True"
return bool(output.strip() == "True")

def path_exists(self, path: str, sudo: bool = False) -> bool:
output = self.node.tools[PowerShell].run_cmdlet(
f"Test-Path {path}",
force_run=True,
sudo=sudo,
)
return output.strip() == "True"
return bool(output.strip() == "True")

def list(self, path: str, sudo: bool = False) -> List[str]:
command = f'Get-ChildItem -Path "{path}" | Select-Object -ExpandProperty Name'
Expand All @@ -106,7 +106,7 @@ def list(self, path: str, sudo: bool = False) -> List[str]:
sudo=sudo,
)
if output:
return output.split()
return List(output.split())
else:
return []

Expand Down
2 changes: 1 addition & 1 deletion lisa/tools/mdadm.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def _exists_pool(self, pool_name: str) -> bool:
fail_on_error=False,
force_run=True,
)
return output.strip() != ""
return bool(output.strip() != "")

def _delete_pool(self, pool_name: str) -> None:
if self._exists_pool(pool_name):
Expand Down

0 comments on commit 25d54d0

Please sign in to comment.