Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.aspect.build/llms.txt

Use this file to discover all available pages before exploring further.

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:
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",
)
Finally, create the linter aspect, typically in tools/lint/linters.bzl:
load("@aspect_rules_lint//lint:pylint.bzl", "lint_pylint_aspect")

pylint = lint_pylint_aspect(
    binary = Label("//tools/lint:pylint"),
    config = Label("//:.pylintrc"),
)

Function: pylint_action

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

Parameters

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

Function: lint_pylint_aspect

A factory function to create a linter aspect.

Parameters

binary
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”, )
config
unknown
required
the pylint config file (pyproject.toml, pylintrc, or .pylintrc)
rule_kinds
unknown
default:"[\"py_binary\", \"py_library\", \"py_test\"]"
which kinds of rules should be visited by the aspect
filegroup_tags
unknown
default:"[\"python\", \"lint-with-pylint\"]"
filegroups tagged with these tags will also be visited by the aspect