Skip to content

Commit

Permalink
Pylint: Enable pointless statement checks
Browse files Browse the repository at this point in the history
  • Loading branch information
avylove authored and squirrelsc committed Jan 12, 2023
1 parent ba094c3 commit e291bd4
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 38 deletions.
3 changes: 1 addition & 2 deletions examples/testsuites/helloworld.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ def hello(self, node: Node, log: Logger) -> None:
priority=1,
)
def bye(self, node: Node) -> None:
# use it once like this way before use short cut
node.tools[Echo]
node.tools.get(Echo) # Ensure echo is in cache
assert_that(str(node.tools.echo("bye!"))).is_equal_to("bye!")

def before_suite(self, log: Logger, **kwargs: Any) -> None:
Expand Down
6 changes: 3 additions & 3 deletions lisa/executable.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ def install(self) -> bool:
# check dependencies
if self.dependencies:
self._log.info("installing dependencies")
for dependency in self.dependencies:
self.node.tools[dependency]
map(self.node.tools.get, self.dependencies)

return self._install()

def run_async(
Expand Down Expand Up @@ -560,7 +560,7 @@ def create(

def get(
self,
tool_type: Union[Type[T], CustomScriptBuilder, str],
tool_type: Union[Type[T], Type[Tool], CustomScriptBuilder, str],
*args: Any,
**kwargs: Any,
) -> T:
Expand Down
19 changes: 9 additions & 10 deletions lisa/schema.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

"""
Schema is dealt with three components,
1. dataclasses. It's a builtin class, uses to define schema of an instance. field()
function uses to describe a field.
2. dataclasses_json. Serializer. config() function customizes this component.
3. marshmallow. Validator. It's wrapped by dataclasses_json. config(mm_field=xxx)
function customizes this component.
"""

import copy
from dataclasses import dataclass, field
from enum import Enum
Expand Down Expand Up @@ -28,16 +37,6 @@
strip_strs,
)

"""
Schema is dealt with three components,
1. dataclasses. It's a builtin class, uses to define schema of an instance. field()
function uses to describe a field.
2. dataclasses_json. Serializer. config() function customizes this component.
3. marshmallow. Validator. It's wrapped by dataclasses_json. config(mm_field=xxx)
function customizes this component.
"""


T = TypeVar("T")


Expand Down
2 changes: 1 addition & 1 deletion lisa/tools/kdump.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def _install_from_src(self) -> None:
tool_path, name_pattern="kexec-tools*", file_type="d"
)
code_path = tool_path.joinpath(kexec_source_folder[0])
self.node.tools[Gcc]
self.node.tools.get(Gcc) # Ensure gcc is installed
make = self.node.tools[Make]
self.node.execute(
"./configure",
Expand Down
2 changes: 1 addition & 1 deletion lisa/tools/lsvmbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def _initialize(self, *args: Any, **kwargs: Any) -> None:
cmd_result = self.node.execute("which python", sudo=True)
if 0 != cmd_result.exit_code:
ln = self.node.tools[Ln]
self.node.tools[Python]
self.node.tools.get(Python)
ln.create_link("/bin/python3", "/usr/bin/python")

def _check_exists(self) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion lisa/tools/stress_ng.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def _install_from_src(self) -> bool:
tool_path = self.get_tool_path()
git = self.node.tools[Git]
git.clone(self.repo, tool_path, ref=self.branch)
self.node.tools[Gcc]
self.node.tools.get(Gcc) # Ensure gcc is installed
make = self.node.tools[Make]
code_path = tool_path.joinpath("stress-ng")
make.make_install(cwd=code_path)
Expand Down
2 changes: 1 addition & 1 deletion lisa/tools/vdsotest.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def _install_from_src(self) -> bool:
tool_path = self.get_tool_path()
git = self.node.tools[Git]
git.clone(self.repo, tool_path, ref=self.branch)
self.node.tools[Gcc]
self.node.tools.get(Gcc)
make = self.node.tools[Make]
code_path = tool_path.joinpath("vdsotest")
self.node.execute("./autogen.sh", cwd=code_path).assert_exit_code()
Expand Down
16 changes: 8 additions & 8 deletions lisa/util/package.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

import importlib
import importlib.util
import sys
from pathlib import Path
from typing import Iterable, Optional

from lisa.util.logger import Logger, get_logger

"""
Reasons to import packages in LISA:
Expand All @@ -24,6 +16,14 @@
"""

import importlib
import importlib.util
import sys
from pathlib import Path
from typing import Iterable, Optional

from lisa.util.logger import Logger, get_logger


def _import_module(
file: Path,
Expand Down
8 changes: 4 additions & 4 deletions microsoft/testsuites/acc/bvt.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,18 +148,18 @@ def verify_sgx(self, log: Logger, node: Node) -> None:
# <cp -r /opt/openenclave/share/openenclave/samples ~/mysamples>

samples_folder = node.get_working_path() / "mysamples"
copy_cmd = "cp -r /opt/openenclave/share/openenclave/samples " + str(
samples_folder
node.execute(
f"cp -r /opt/openenclave/share/openenclave/samples {samples_folder}",
shell=True,
)
node.execute(copy_cmd, shell=True)

# Run Hello World and Remote Attestation
helloworld_dir = samples_folder / "helloworld"
attestation_dir = samples_folder / "attestation"
source_command = ". /opt/openenclave/share/openenclave/openenclaverc"
fail_msg = "HELLO WORLD TEST FAILED"

node.tools[Make]
node.tools.get(Make) # Ensure make is installed
result = node.execute(
f"{source_command} && make build && make run",
cwd=helloworld_dir,
Expand Down
2 changes: 1 addition & 1 deletion microsoft/testsuites/core/hv_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def reload_hyperv_modules(self, case_name: str, log: Logger, node: Node) -> None
if isinstance(node.os, Redhat):
try:
log.debug("Checking LIS installation before reload.")
node.tools[LisDriver]
node.tools.get(LisDriver)
except Exception:
log.debug("Updating LIS failed. Moving on to attempt reload.")

Expand Down
8 changes: 4 additions & 4 deletions microsoft/testsuites/network/sriov.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,10 +691,10 @@ def verify_sriov_interrupts_change(self, environment: Environment) -> None:
):
matched_server_nic_info = server_nic_info
break
assert (
matched_server_nic_info
), "not found the server nic has the same subnet of"
f" {client_nic_info.ip_addr}"
assert matched_server_nic_info, (
"not found the server nic has the same subnet of"
f" {client_nic_info.ip_addr}"
)

# 3. Start iperf3 for 120 seconds with 128 threads on client node.
client_iperf3.run_as_client(
Expand Down
2 changes: 0 additions & 2 deletions pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ disable=
missing-timeout,
modified-iterating-list,
no-member,
pointless-statement,
pointless-string-statement,
redefined-argument-from-local,
redefined-outer-name,
super-init-not-called,
Expand Down

0 comments on commit e291bd4

Please sign in to comment.