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 flake8 lint aspect that visits py_library rules. Typical usage: First, fetch the flake8 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 = "flake8",
    pkg = "@pip//flake8:pkg",
)
Finally, create the linter aspect, typically in tools/lint/linters.bzl:
load("@aspect_rules_lint//lint:flake8.bzl", "lint_flake8_aspect")

flake8 = lint_flake8_aspect(
    binary = Label("//tools/lint:flake8"),
    config = Label("//:.flake8"),
)

Function: flake8_action

Run flake8 as an action under Bazel. Based on https://flake8.pycqa.org/en/latest/user/invocation.html

Parameters

ctx
unknown
required
Bazel Rule or Aspect evaluation context
executable
unknown
required
label of the flake8 program
srcs
unknown
required
python files to be linted
config
unknown
required
label of the flake8 config file (setup.cfg, tox.ini, or .flake8)
stdout
unknown
required
output file containing stdout of flake8
exit_code
unknown
default:"None"
output file containing exit code of flake8 If None, then fail the build when flake8 exits non-zero.
options
unknown
default:"[]"
additional command-line options, see https://flake8.pycqa.org/en/latest/user/options.html

Function: lint_flake8_aspect

A factory function to create a linter aspect. Attrs: binary: a flake8 executable. Can be obtained 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 = “flake8”, pkg = “@pip//flake8:pkg”, ) config: the flake8 config file (setup.cfg, tox.ini, or .flake8)

Parameters

binary
unknown
required
config
unknown
required
rule_kinds
unknown
default:"[\"py_binary\", \"py_library\"]"