Skip to main content
API for declaring a Ty lint aspect that visits py_binary, library, test rules. Typical usage: Ty 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:

Function: ty_action

Run ty as an action under Bazel. ty supports persistent configuration files at both the project- and user-level as documented here: https://docs.astral.sh/ty/configuration/ 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 ty actions.

Parameters

unknown
required
Bazel Rule or Aspect evaluation context
unknown
required
label of the ty program
unknown
required
python files to be linted
unknown
required
depset of transitive Python sources from dependencies
unknown
required
labels of ty config files (pyproject.toml, ty.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 ty exits non-zero. https://docs.astral.sh/ty/reference/exit-codes/
unknown
default:"{}"
environment variables for ty
unknown
default:"[]"
list of paths to add as —extra-search-path for third-party module resolution
unknown
default:"True"
whether to enable color output (—color always) or disable it (—color never)

Function: lint_ty_aspect

A factory function to create a linter aspect. Attrs: binary: a ty executable configs: ty config file(s) (pyproject.toml, ty.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-ty\"]"