From 710760ec9ea1634f8e4361d468ec4b2e0dfc20ec Mon Sep 17 00:00:00 2001 From: Tiago Nobrega Date: Thu, 15 Jun 2023 09:46:46 -0300 Subject: [PATCH] lint: re-add pylint Since ruff is currently disabled (pending issue #146), temporarily add pylint so that we have at least some form of "stylistic" linting of the code. Once we add ruff we can undo this commit, remove .pylintrc and remove the many "# pylint:" comments on the code itself. --- .pylintrc | 4 ++-- craft_cli/messages.py | 4 ++-- pyproject.toml | 3 +++ tox.ini | 6 ++++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.pylintrc b/.pylintrc index ad4e341..abb4766 100644 --- a/.pylintrc +++ b/.pylintrc @@ -547,5 +547,5 @@ preferred-modules= # Exceptions that will emit a warning when being caught. Defaults to # "BaseException, Exception". -overgeneral-exceptions=BaseException, - Exception +overgeneral-exceptions=builtins.BaseException, + builtins.Exception diff --git a/craft_cli/messages.py b/craft_cli/messages.py index 1135962..fd1bd1f 100644 --- a/craft_cli/messages.py +++ b/craft_cli/messages.py @@ -360,9 +360,9 @@ def _active_guard(ignore_when_stopped: bool = False) -> Callable[..., Any]: """ def decorator(wrapped_func: FuncT) -> FuncT: - def func( + def func( # pylint: disable=inconsistent-return-statements self, *args: Any, **kwargs: Any - ) -> Any: # pylint: disable=inconsistent-return-statements + ) -> Any: if not self._initiated: # pylint: disable=protected-access raise RuntimeError("Emitter needs to be initiated first") if self._stopped: # pylint: disable=protected-access diff --git a/pyproject.toml b/pyproject.toml index 4c944e0..d0813d6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,6 +53,9 @@ dev = [ lint = [ "black==23.3.0", "codespell[toml]==2.2.4", + "pylint==2.17.4", + "pylint-fixme-info==1.0.3", + "pylint-pytest==1.1.2", "ruff==0.0.269", "yamllint==1.32.0" ] diff --git a/tox.ini b/tox.ini index b2eae2f..4630f4e 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] env_list = # Environments to run when called with no parameters. - lint-{black,ruff,pyright,shellcheck,codespell,docs} + lint-{black,ruff,pyright,shellcheck,codespell,docs,pylint} test-{py38,py310,py311} minversion = 4.5 # Tox will use these requirements to bootstrap a venv if necessary. @@ -56,7 +56,7 @@ runner = ignore_env_name_mismatch find = git ls-files filter = file --mime-type -Nnf- | grep shellscript | cut -f1 -d: -[testenv:lint-{black,ruff,shellcheck,codespell,yaml}] +[testenv:lint-{black,ruff,shellcheck,codespell,yaml,pylint}] description = Lint the source code base = testenv, lint labels = lint @@ -70,6 +70,8 @@ commands = shellcheck: xargs -ra {env_tmp_dir}/shellcheck_files shellcheck codespell: codespell --toml {tox_root}/pyproject.toml {posargs} yaml: yamllint {posargs} . + pylint: pylint craft_cli {posargs} --ignore _version.py + pylint: pylint tests {posargs} --disable=missing-module-docstring,missing-function-docstring,redefined-outer-name,protected-access,duplicate-code,too-many-lines,missing-class-docstring,too-few-public-methods [testenv:lint-{mypy,pyright}] description = Static type checking