Reusable aspect_rules_lint aspect factories for Python linting (ruff, pylint, ty), shared across score repos.
├── BUILD
├── linters.bzl
├── macros.bzl
└── README.mdruff_lint_aspect(config)— a ruff lint aspect using aspect_rules_lint's built-in ruff binary (@aspect_rules_lint//lint:ruff_bin, an alias for the same@multitool//tools/ruffthatthird_party/formatuses for formatting, so linting and formatting always run the same ruff version).pylint_lint_aspect(binary, config)— a pylint lint aspect. Pylint is a pure-python package, not a static binary, so it isn't provided byrules_multitool: the caller must add it to their own pip requirements and declare apy_console_script_binarytarget for it (see//third_party/lint:pylintin this repo for a working example).ty_lint_aspect(config)— a ty type-checking lint aspect using aspect_rules_lint's built-in ty binary (@aspect_rules_lint//lint:ty_bin, an alias for@multitool//tools/ty, the same default multitool hub used for ruff, so no extra pip dependency is required).
This repo's own dogfooding declarations (ruff, pylint, ty aspects), wired
up via .bazelrc's build:lint config below. Consumers replicate this file
in their own repo (see Usage).
Rust linting (clippy) doesn't need anything from this module: rules_rust
(already a score_tooling dependency) ships native rust_clippy_aspect /
rust_clippy_test support directly.
Aspects must be declared at the top level of your own repo's linters.bzl,
so that Label("//...") config-file references resolve relative to your
repo, not to score_tooling:
load("@score_tooling//third_party/lint:macros.bzl", "pylint_lint_aspect", "ruff_lint_aspect", "ty_lint_aspect")
ruff = ruff_lint_aspect(config = Label("//:pyproject.toml"))
pylint = pylint_lint_aspect(
binary = Label("//third_party/lint:pylint"),
config = Label("//:pyproject.toml"),
)
ty = ty_lint_aspect(config = Label("//:pyproject.toml"))Then run/check them via a .bazelrc config (see this repo's own .bazelrc
for a working example):
build:lint --aspects=//third_party/lint:linters.bzl%ruff,//third_party/lint:linters.bzl%pylint,//third_party/lint:linters.bzl%ty
build:lint --output_groups=+rules_lint_human
bazel build --config=lint //...