Module ext_tool_checks

Source
Expand description

Optional checks for file types other than Rust source

Handles python tool version management via a virtual environment in build/venv.

Β§Functional outline

  1. Run tidy with an extra option: --extra-checks=py,shell, --extra-checks=py:lint, or similar. Optionally provide specific configuration after a double dash (--extra-checks=py -- foo.py)
  2. Build configuration based on args/environment:
    • Formatters by default are in check only mode
    • If in CI (TIDY_PRINT_DIFF=1 is set), check and print the diff
    • If --bless is provided, formatters may run
    • Pass any additional config after the --. If no files are specified, use a default.
  3. Print the output of the given command. If it fails and TIDY_PRINT_DIFF is set, rerun the tool to print a suggestion diff (for e.g. CI)

EnumsΒ§

Error πŸ”’

ConstantsΒ§

MIN_PY_REV πŸ”’
MIN_PY_REV_STR πŸ”’
PIP_REQ_PATH πŸ”’
REL_PY_PATH πŸ”’
RUFF_CACHE_PATH πŸ”’
Location within build directory
RUFF_CONFIG_PATH πŸ”’

FunctionsΒ§

check
check_impl πŸ”’
create_venv_at_path πŸ”’
Attempt to create a virtualenv at this path. Cycles through all expected valid python versions to find one that is installed.
find_with_extension πŸ”’
Check git for tracked files matching an extension
get_or_create_venv πŸ”’
Create a virtuaenv at a given path if it doesn’t already exist, or validate the install if it does. Returns the path to that venv’s python executable.
install_requirements πŸ”’
merge_args πŸ”’
Helper to create cfg1 cfg2 -- file1 file2 output
py_runner πŸ”’
Run a python command with given arguments. py_path should be a virtualenv.
run_ruff πŸ”’
shellcheck_runner πŸ”’
Check that shellcheck is installed then run it at the given path
try_create_venv πŸ”’
verify_py_version πŸ”’
Parse python’s version output (Python x.y.z) and ensure we have a suitable version.