Skip to main content
API for declaring a pylint lint aspect that visits Python rules. Typical usage: First, fetch the pylint package via your standard requirements file and pip calls. Then, declare a binary target for it, typically in tools/lint/BUILD.bazel:
Finally, create the linter aspect, typically in tools/lint/linters.bzl:

Function: pylint_action

Run pylint as an action under Bazel. Based on https://pylint.readthedocs.io/en/stable/user_guide/run.html

Parameters

unknown
required
Bazel Rule or Aspect evaluation context
unknown
required
label of the pylint program
unknown
required
python files to be linted
unknown
required
label of the pylint config file (pyproject.toml, .pylintrc, or setup.cfg)
unknown
required
output file containing stdout of pylint
unknown
default:"None"
output file containing exit code of pylint If None, then fail the build when pylint exits non-zero.
unknown
default:"[]"
additional command-line options

Function: lint_pylint_aspect

A factory function to create a linter aspect.

Parameters

unknown
required
a pylint executable. Obtain from rules_python like so:load(“@rules_python//python/entry_points:py_console_script_binary.bzl”, “py_console_script_binary”)py_console_script_binary( name = “pylint”, pkg = “@pip//pylint:pkg”, )
unknown
required
the pylint config file (pyproject.toml, pylintrc, or .pylintrc)
unknown
default:"[\"py_binary\", \"py_library\", \"py_test\"]"
which kinds of rules should be visited by the aspect
unknown
default:"[\"python\", \"lint-with-pylint\"]"
filegroups tagged with these tags will also be visited by the aspect