AAP-85334: Replace Black + Flake8 with Ruff

Migrate Python linting and formatting toolchain from Black (formatter)
and Flake8 (linter) to Ruff, which provides both in a single tool.

- pyproject.toml: remove [tool.black], add [tool.ruff] config sections
- tox.ini: replace black+flake8 deps/commands with ruff in linters env
- awxkit/tox.ini: replace flake8 with ruff in lint env
- Makefile: replace `black` target with `format` + `lint`, keep `black`
  as legacy alias, update `check` and `api-lint`
- pre-commit.sh: use `ruff format --check`, honor AWX_IGNORE_RUFF
- requirements_dev.txt: swap black/flake8 for ruff
- Dockerfile.j2: install ruff instead of black
- CONTRIBUTING.md: update tool references
- Fix noqa comments to use # separator instead of ; (ruff requirement)
- Add noqa: F841 for false positive in awxkit/cli/__init__.py

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dirk Julich
2026-08-20 18:35:23 +02:00
co-authored by Claude Opus 4.6
parent b84931a49b
commit 4b73e1264b
15 changed files with 55 additions and 51 deletions
+14 -6
View File
@@ -348,9 +348,17 @@ run-ws-heartbeat:
reports:
mkdir -p $@
black: reports
@command -v black >/dev/null 2>&1 || { echo "could not find black on your PATH, you may need to \`pip install black\`, or set AWX_IGNORE_BLACK=1" && exit 1; }
@(set -o pipefail && $@ $(BLACK_ARGS) awx awxkit awx_collection | tee reports/$@.report)
## awx_collection is excluded: ansible-test sanity runs its own linters which conflict with ruff
format: reports
@command -v ruff >/dev/null 2>&1 || { echo "could not find ruff on your PATH, you may need to \`pip install ruff\`" && exit 1; }
@(set -o pipefail && ruff format $(RUFF_FORMAT_ARGS) awx awxkit | tee reports/format.report)
lint: reports
@command -v ruff >/dev/null 2>&1 || { echo "could not find ruff on your PATH, you may need to \`pip install ruff\`" && exit 1; }
ruff check awx awxkit
## Legacy alias
black: format
$(GIT_COMMON_DIR)/hooks/pre-commit:
ln -sf ../../pre-commit.sh $(GIT_COMMON_DIR)/hooks/pre-commit
@@ -369,11 +377,11 @@ genschema-yaml: awx-link reports
fi; \
$(MANAGEMENT_COMMAND) spectacular --format openapi --file schema.yaml
check: black
check: format
api-lint:
BLACK_ARGS="--check" $(MAKE) black
flake8 awx
RUFF_FORMAT_ARGS="--check" $(MAKE) format
$(MAKE) lint
yamllint -s .
## Run egg_info_dev to generate awx.egg-info for development.