PyLint fixes

This commit is contained in:
Ivan Kravets
2021-02-27 17:13:30 +02:00
parent 20096be990
commit 58947d91a6
14 changed files with 38 additions and 45 deletions

View File

@ -52,6 +52,7 @@ def BoardConfig(env, board=None):
except (AssertionError, UnknownBoard) as e:
sys.stderr.write("Error: %s\n" % str(e))
env.Exit(1)
return None
def GetFrameworkScript(env, framework):

View File

@ -230,7 +230,7 @@ class CppcheckCheckTool(CheckToolBase):
project_files = self.get_project_target_files(self.options["patterns"])
languages = ("c", "c++")
if not any([project_files[t] for t in languages]):
if not any(project_files[t] for t in languages):
click.echo("Error: Nothing to check.")
return True
for language in languages:

View File

@ -192,7 +192,7 @@ def configure_esp32_load_cmds(debug_options, configuration):
debug_options["load_cmds"] != ["load"],
"xtensa-esp32" not in configuration.get("cc_path", ""),
not flash_images,
not all([isfile(item["path"]) for item in flash_images]),
not all(isfile(item["path"]) for item in flash_images),
]
if any(ignore_conds):
return debug_options["load_cmds"]

View File

@ -257,15 +257,13 @@ class ProjectRPC:
return arduino_project_dir
is_arduino_project = any(
[
os.path.isfile(
os.path.join(
arduino_project_dir,
"%s.%s" % (os.path.basename(arduino_project_dir), ext),
)
os.path.isfile(
os.path.join(
arduino_project_dir,
"%s.%s" % (os.path.basename(arduino_project_dir), ext),
)
for ext in ("ino", "pde")
]
)
for ext in ("ino", "pde")
)
if not is_arduino_project:
raise jsonrpc.exceptions.JSONRPCDispatchException(

View File

@ -128,9 +128,9 @@ def cli( # pylint: disable=redefined-builtin
not environment and default_envs and envname not in default_envs,
testname != "*"
and patterns["filter"]
and not any([fnmatch(testname, p) for p in patterns["filter"]]),
and not any(fnmatch(testname, p) for p in patterns["filter"]),
testname != "*"
and any([fnmatch(testname, p) for p in patterns["ignore"]]),
and any(fnmatch(testname, p) for p in patterns["ignore"]),
]
if any(skip_conditions):
results.append({"env": envname, "test": testname})

View File

@ -95,7 +95,7 @@ class EmbeddedTestProcessor(TestProcessorBase):
if isinstance(line, bytes):
line = line.decode("utf8", "ignore")
self.on_run_out(line)
if all([l in line for l in ("Tests", "Failures", "Ignored")]):
if all(l in line for l in ("Tests", "Failures", "Ignored")):
break
ser.close()
return not self._run_failed

View File

@ -568,6 +568,7 @@ class LibraryPropertiesManifestParser(BaseManifestParser):
continue
found = True
item["maintainer"] = True
# pylint: disable=unsupported-membership-test
if not item.get("email") and email and "@" in email:
item["email"] = email
if not found:

View File

@ -252,6 +252,7 @@ class PlatformBase( # pylint: disable=too-many-instance-attributes,too-many-pub
click.secho(
"Could not install Python packages -> %s" % e, fg="red", err=True
)
return None
def uninstall_python_packages(self):
if not self.python_packages:

View File

@ -23,7 +23,7 @@ def test_board_json_output(clirunner, validate_cliresult):
validate_cliresult(result)
boards = json.loads(result.output)
assert isinstance(boards, list)
assert any(["mbed" in b["frameworks"] for b in boards])
assert any("mbed" in b["frameworks"] for b in boards)
def test_board_raw_output(clirunner, validate_cliresult):

View File

@ -70,10 +70,8 @@ def test_init_ide_vscode(clirunner, validate_cliresult, tmpdir):
validate_cliresult(result)
validate_pioproject(str(tmpdir))
assert all(
[
tmpdir.join(".vscode").join(f).check()
for f in ("c_cpp_properties.json", "launch.json")
]
tmpdir.join(".vscode").join(f).check()
for f in ("c_cpp_properties.json", "launch.json")
)
assert (
"framework-arduino-avr"
@ -113,7 +111,7 @@ def test_init_ide_eclipse(clirunner, validate_cliresult):
result = clirunner.invoke(cmd_init, ["-b", "uno", "--ide", "eclipse"])
validate_cliresult(result)
validate_pioproject(getcwd())
assert all([isfile(f) for f in (".cproject", ".project")])
assert all(isfile(f) for f in (".cproject", ".project"))
def test_init_special_board(clirunner, validate_cliresult):

View File

@ -172,27 +172,23 @@ def test_global_lib_list(clirunner, validate_cliresult):
result = clirunner.invoke(cmd_lib, ["-g", "list"])
validate_cliresult(result)
assert all(
[
n in result.output
for n in (
"Source: https://github.com/Pedroalbuquerque/ESP32WebServer/archive/master.zip",
"Version: 5.10.1",
"Source: git+https://github.com/gioblu/PJON.git#3.0",
"Version: 3.0.0+sha.1fb26fd",
)
]
n in result.output
for n in (
"Source: https://github.com/Pedroalbuquerque/ESP32WebServer/archive/master.zip",
"Version: 5.10.1",
"Source: git+https://github.com/gioblu/PJON.git#3.0",
"Version: 3.0.0+sha.1fb26fd",
)
)
result = clirunner.invoke(cmd_lib, ["-g", "list", "--json-output"])
assert all(
[
n in result.output
for n in (
"__pkg_dir",
'"__src_url": "git+https://github.com/gioblu/PJON.git#6.2"',
'"version": "5.10.1"',
)
]
n in result.output
for n in (
"__pkg_dir",
'"__src_url": "git+https://github.com/gioblu/PJON.git#6.2"',
'"version": "5.10.1"',
)
)
items1 = [i["name"] for i in json.loads(result.output)]
items2 = [
@ -316,7 +312,7 @@ def test_global_lib_uninstall(clirunner, validate_cliresult, isolated_pio_core):
def test_lib_show(clirunner, validate_cliresult):
result = clirunner.invoke(cmd_lib, ["show", "64"])
validate_cliresult(result)
assert all([s in result.output for s in ("ArduinoJson", "Arduino", "Atmel AVR")])
assert all(s in result.output for s in ("ArduinoJson", "Arduino", "Atmel AVR"))
result = clirunner.invoke(cmd_lib, ["show", "OneWire", "--json-output"])
validate_cliresult(result)
assert "OneWire" in result.output
@ -333,10 +329,8 @@ def test_lib_stats(clirunner, validate_cliresult):
result = clirunner.invoke(cmd_lib, ["stats"])
validate_cliresult(result)
assert all(
[
s in result.output
for s in ("UPDATED", "POPULAR", "https://platformio.org/lib/show")
]
s in result.output
for s in ("UPDATED", "POPULAR", "https://platformio.org/lib/show")
)
result = clirunner.invoke(cmd_lib, ["stats", "--json-output"])

View File

@ -103,7 +103,7 @@ def test_list_json_output(clirunner, validate_cliresult):
def test_list_raw_output(clirunner, validate_cliresult):
result = clirunner.invoke(cli_platform.platform_list)
validate_cliresult(result)
assert all([s in result.output for s in ("atmelavr", "espressif8266")])
assert all(s in result.output for s in ("atmelavr", "espressif8266"))
def test_update_check(clirunner, validate_cliresult, isolated_pio_core):

View File

@ -34,7 +34,7 @@ def test_local_env():
if result["returncode"] != 1:
pytest.fail(str(result))
# pylint: disable=unsupported-membership-test
assert all([s in result["err"] for s in ("PASSED", "FAILED")]), result["out"]
assert all(s in result["err"] for s in ("PASSED", "FAILED")), result["out"]
def test_multiple_env_build(clirunner, validate_cliresult, tmpdir):

View File

@ -21,7 +21,7 @@ def test_update(clirunner, validate_cliresult, isolated_pio_core):
matches = ("Platform Manager", "Library Manager")
result = clirunner.invoke(cmd_update, ["--only-check"])
validate_cliresult(result)
assert all([m in result.output for m in matches])
assert all(m in result.output for m in matches)
result = clirunner.invoke(cmd_update)
validate_cliresult(result)
assert all([m in result.output for m in matches])
assert all(m in result.output for m in matches)