summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2026-11-12 17:32:39 +0100
committerChristian Breunig <christian@breunig.cc>2026-11-12 17:32:39 +0100
commitc521a7c5fc41b912d6ec348a04bdf609dd269fa2 (patch)
tree83624d4c431c8d95557b657f429a1608b9ef9b96
parent305fcdc8614196d9c2a97491e1862cd00bbd7d12 (diff)
downloadvyos-1x-c521a7c5fc41b912d6ec348a04bdf609dd269fa2.tar.gz
vyos-1x-c521a7c5fc41b912d6ec348a04bdf609dd269fa2.zip
Makefile: T9615: run pylint error checks on all Python files
Error checks only covered parts of the tree, so broken imports in helpers, utils, validators and Python subpackages went unnoticed. Unused imports were checked in a separate run. Both checks now run in a single pass over every Python file, including scripts without a .py extension. Modules missing from the build environment, generated on install or imported via sys.path changes are ignored globally, as are protoc generated files.
-rw-r--r--Makefile9
-rw-r--r--pyproject.toml25
2 files changed, 30 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 8dbb9ae3d..eac0887b4 100644
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,7 @@ LIBS := -lzmq
CFLAGS :=
BUILD_ARCH := $(shell dpkg-architecture -q DEB_BUILD_ARCH)
J2LINT := $(shell command -v j2lint 2> /dev/null)
+PYLINT_FILES := $(shell (git ls-files '*.py' src/migration-scripts; git grep -lE '^\#!.*python' -- ':!*.py') | sort -u)
config_xml_src = $(wildcard interface-definitions/*.xml.in)
config_xml_obj = $(config_xml_src:.xml.in=.xml)
@@ -117,9 +118,11 @@ check_scripts_not_executable:
.PHONY: pylint
pylint: interface_definitions
@echo Running "pylint ..."
- @set -e; \
- PYTHONPATH="python/:smoketest/scripts/cli/" pylint --jobs 0 --errors-only $(shell git ls-files python/**/*.py src/conf_mode/*.py src/op_mode/*.py src/migration-scripts src/services/vyos* smoketest/scripts); \
- PYTHONPATH=python/ pylint --jobs 0 --disable=all --enable=W0611 $(shell git ls-files *.py src/migration-scripts src/services)
+ # relative-beyond-top-level: the GraphQL scripts import relative to their
+ # package only when loaded as one
+ PYTHONPATH="python/:smoketest/scripts/cli/" pylint --jobs 0 \
+ --disable=all --enable=E,F,W0611 --disable=relative-beyond-top-level \
+ $(PYLINT_FILES)
.PHONY: j2lint
j2lint:
diff --git a/pyproject.toml b/pyproject.toml
index e1df19cbd..75bb5aa12 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,5 +1,28 @@
[tool.black]
skip-string-normalization = true
+[tool.pylint.main]
+# generated by protoc
+ignore-patterns = ['.*_pb2\.py$']
+
[tool.pylint.typecheck]
-ignored-modules = ["vici"] \ No newline at end of file
+# not installed in the build environment, generated on install, or imported
+# via sys.path changes
+ignored-modules = [
+ "ariadne",
+ "configtree",
+ "defaults",
+ "generate_cache",
+ "graphql",
+ "makefun",
+ "multipart",
+ "op_definition",
+ "pam",
+ "pydantic",
+ "pyroute2",
+ "vici",
+ "vpp_papi",
+ "vyos.xml_ref",
+]
+# pydantic v2 API, the build environment has v1
+generated-members = ["model_.*"]