diff options
author | Jeremy Bettis <jbettis@google.com> | 2022-02-08 13:15:23 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2022-02-12 04:29:46 +0000 |
commit | 0ab6c10da0394f2887a26b1ac7c696baed801517 (patch) | |
tree | 085451ea93585ee33589b730ebce3ed77b8fc13b | |
parent | 4a4bc3599b8885d55eb0e7650cfe758c82ecc23a (diff) | |
download | chrome-ec-0ab6c10da0394f2887a26b1ac7c696baed801517.tar.gz |
zmake: Add .pylintrc and some fixes for pylint
With this .pylintrc, and these tweaks, there are no errors reported by
cros lint. Many warnings, but no errors.
Added a pylint call to run_tests.sh. It only checks for errors, once we
get the warnings cleaned up, we should change it to call cros lint
instead.
BRANCH=None
BUG=b:217969201
TEST=run_tests.sh
Change-Id: I1ad75fda3d6f818f1d1c66654823bac97ce09942
Signed-off-by: Jeremy Bettis <jbettis@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3449124
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Commit-Queue: Jeremy Bettis <jbettis@chromium.org>
Tested-by: Jeremy Bettis <jbettis@chromium.org>
-rw-r--r-- | zephyr/zmake/.pylintrc | 11 | ||||
-rwxr-xr-x | zephyr/zmake/run_tests.sh | 6 | ||||
-rw-r--r-- | zephyr/zmake/zmake/configlib.py | 6 | ||||
-rw-r--r-- | zephyr/zmake/zmake/jobserver.py | 6 | ||||
-rw-r--r-- | zephyr/zmake/zmake/project.py | 4 |
5 files changed, 26 insertions, 7 deletions
diff --git a/zephyr/zmake/.pylintrc b/zephyr/zmake/.pylintrc new file mode 100644 index 0000000000..dc6b05c654 --- /dev/null +++ b/zephyr/zmake/.pylintrc @@ -0,0 +1,11 @@ +[MASTER] +init-hook='import sys; sys.path.append("/usr/lib64/python3.6/site-packages")' + +[MESSAGES CONTROL] + +disable=bad-continuation,bad-whitespace,format,fixme + +[format] + +max-line-length=88 +string-quote=double diff --git a/zephyr/zmake/run_tests.sh b/zephyr/zmake/run_tests.sh index 4796704440..54d0bf98a4 100755 --- a/zephyr/zmake/run_tests.sh +++ b/zephyr/zmake/run_tests.sh @@ -36,3 +36,9 @@ flake8 . # Check auto-generated README.md is as expected. python -m zmake generate-readme --diff + +# Check that cros lint has no errors, we can't actually call cros lint +# because there is no way to pass the -E flag to pylint. +# When there are no warnings, switch this to `cros lint` +find . -name '*.py' -print0 | xargs -0 \ + /mnt/host/source/chromite/cli/cros/pylint-2 '--rcfile=.pylintrc' -E diff --git a/zephyr/zmake/zmake/configlib.py b/zephyr/zmake/zmake/configlib.py index 3c6aa649c5..1e6223b2cb 100644 --- a/zephyr/zmake/zmake/configlib.py +++ b/zephyr/zmake/zmake/configlib.py @@ -8,8 +8,10 @@ import zmake.output_packers def _register_project(**kwargs): - kwargs.setdefault("project_dir", here) # noqa: F821 - register_project(**kwargs) # noqa: F821 + kwargs.setdefault( + "project_dir", here # noqa: F821 pylint: disable=undefined-variable + ) + register_project(**kwargs) # noqa: F821 pylint: disable=undefined-variable def register_host_project(**kwargs): diff --git a/zephyr/zmake/zmake/jobserver.py b/zephyr/zmake/zmake/jobserver.py index 69199a2dc8..0d02a2c8d6 100644 --- a/zephyr/zmake/zmake/jobserver.py +++ b/zephyr/zmake/zmake/jobserver.py @@ -39,7 +39,7 @@ class JobClient: """Get the environment variables necessary to share the job server.""" return {} - def popen(self, *args, **kwargs): + def popen(self, argv, **kwargs): """Start a process using subprocess.Popen All other arguments are passed to subprocess.Popen. @@ -51,8 +51,8 @@ class JobClient: kwargs["env"].update(self.env()) logger = logging.getLogger(self.__class__.__name__) - logger.debug("Running %s", zmake.util.repr_command(*args)) - return subprocess.Popen(*args, **kwargs) + logger.debug("Running %s", zmake.util.repr_command(argv)) + return subprocess.Popen(argv, **kwargs) def run(self, *args, claim_job=True, **kwargs): """Run a process using subprocess.run, optionally claiming a job. diff --git a/zephyr/zmake/zmake/project.py b/zephyr/zmake/zmake/project.py index 1bac91cbc4..a3d786f0cd 100644 --- a/zephyr/zmake/zmake/project.py +++ b/zephyr/zmake/zmake/project.py @@ -9,7 +9,7 @@ import pathlib import zmake.build_config as build_config import zmake.configlib as configlib -import zmake.modules as modules +import zmake.modules import zmake.toolchains as toolchains @@ -92,7 +92,7 @@ class ProjectConfig: supported_toolchains: "list[str]" output_packer: type modules: "list[str]" = dataclasses.field( - default_factory=lambda: modules.known_modules, + default_factory=lambda: zmake.modules.known_modules, ) is_test: bool = dataclasses.field(default=False) dts_overlays: "list[str]" = dataclasses.field(default_factory=list) |