Documentation for @aspect_rules_lint@v2.3.0 — View source
binary, library, test rules.
Typical usage:
Ruff is provided as a built-in tool by rules_lint. To use the built-in version,
create the linter aspect, typically in tools/lint/linters.bzl:
Using a specific ruff version
InMODULE.bazel, fetch the desired version from https://github.com/astral-sh/ruff/releases.
In tools/lint/BUILD.bazel, select the tool for the host platform:
@multitool:
Function: ruff_action
Run ruff as an action under Bazel.
Ruff will select the configuration file to use for each source file, as documented here:
https://docs.astral.sh/ruff/configuration/#config-file-discovery
Note: all config files are passed to the action.
This means that a change to any config file invalidates the action cache entries for ALL
ruff actions.
However, this is important because:
- ruff has an
extendfield, so it may need to read more than one config file - ruff’s logic for selecting the appropriate config needs to read the file content to detect a
[tool.ruff]section.
Parameters
unknown
required
Bazel Rule or Aspect evaluation context
unknown
required
label of the ruff program
unknown
required
python files to be linted
unknown
required
labels of ruff config files (pyproject.toml, ruff.toml, or .ruff.toml)
unknown
required
output file of linter results to generate
unknown
default:"None"
output file to write the exit code.
If None, then fail the build when ruff exits non-zero.
See https://github.com/astral-sh/ruff/blob/dfe4291c0b7249ae892f5f1d513e6f1404436c13/docs/linter.md#exit-codes
unknown
default:"{}"
environment variaables for ruff
unknown
default:"None"
output file for patch (optional). If provided, uses run_patcher instead of run_shell.
Function: lint_ruff_aspect
A factory function to create a linter aspect.
Attrs:
binary: a ruff executable
configs: ruff config file(s) (pyproject.toml, ruff.toml, or .ruff.toml)
rule_kinds: which kinds of rules should be visited by the aspect
filegroup_tags: filegroups tagged with these tags will be visited by the aspect in addition to Python rule kinds
Parameters
unknown
required
unknown
required
unknown
default:"[\"py_binary\", \"py_library\", \"py_test\"]"
unknown
default:"[\"python\", \"lint-with-ruff\"]"
Repository rule: ruff_workaround_20269
Workaround for https://github.com/bazelbuild/bazel/issues/20269
Attributes
name
required
A unique name for this repository.
dictionary: String → String
In
WORKSPACE context only: a dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.For example, an entry "@foo": "@bar" declares that, for any time this repository depends on @foo (such as a dependency on @foo//some:target, it should actually resolve that dependency within globally-declared @bar (@bar//some:target).This attribute is not supported in MODULE.bazel context (when invoking a repository rule inside a module extension’s implementation function).string
default:"\"\""
string
default:"\"\""
string
default:"\"\""
unlike http_archive, any value causes us to pass —strip-components=1 to tar
string
default:"\"\""

