Decided in #91 (part of the map #87). No hook or CI job lints the Python or shell in this repository today: about 1,260 lines under scripts/ and tests/scripts/ plus scripts/dev-setup.sh are held by review alone. This issue adds the two standard tools as controls. It depends on no other open decision.
Add
ruff as pre-commit hooks from its official hook repository: the linter and the formatter.
Configuration in one committed file, ruff.toml, at the repository root. Use ruff's defaults and additionally select the complexity and function-size rules (C901, PLR0912, PLR0915) at their default thresholds. Do not tune a threshold in this issue.
ruff.toml is a new top-level file: add it to build_ignore in galaxy.yml.
shellcheck as a pre-commit hook (the shellcheck-py hook, so no system package is needed), at its default severity, with no .shellcheckrc unless a finding requires one.
Both run in CI through the existing Lint job, which already runs the pre-commit hooks. No new workflow and no new script.
Fix what they find
Format the existing Python with ruff format in its own commit, separate from any hand edits, so the diff is reviewable.
Fix lint findings where the fix is small and safe.
Where a finding is not worth fixing now, suppress it inline with the rule code and a reason (# noqa: C901 reason, # shellcheck disable=SC… reason). No global ignore of a rule.
scripts/check_image_versions.py, scripts/bump_image_versions.py and scripts/check_bot_pr_diff.py may be removed or rewritten by #96. Do not restructure them here. If one needs more than a handful of complexity suppressions, use a per-file entry for that file in ruff.toml with a comment naming #96, and list it in the pull request.
Notes
.pre-commit-config.yaml is an image input: this is the two-PR loop. The first pull request carries the hook change and the PATCH bump of the ci image version (scripts/bump_image_versions.py); the consumer pins move in a second pull request after the image is built on main.
Each pushed image layer must stay under 100 MB. The new hook environments are baked into the ci image; check the layer sizes the build prints.
Renovate already follows hook rev: lines, so the new hooks need no Renovate change. renovate.json is not touched.
No changelog fragment: nothing a consumer installs changes.
The existing script tests under tests/scripts/ must still pass after formatting and fixes.
Not in this issue
A check for comment length or file length: decided against in #91 (no standard tool, no custom checker).
ansible-lint's complexity rule: #93 sets its number.
pre-commit run --all-files passes locally with the new hooks, and the Lint check passes on the pull request.
A deliberately bad change (an unused import in a script, an unquoted variable in dev-setup.sh) makes the corresponding hook fail; say in the pull request that this was tried.
Every suppression carries a rule code and a reason.
Decided in #91 (part of the map #87). No hook or CI job lints the Python or shell in this repository today: about 1,260 lines under `scripts/` and `tests/scripts/` plus `scripts/dev-setup.sh` are held by review alone. This issue adds the two standard tools as controls. It depends on no other open decision.
## Add
- **`ruff`** as pre-commit hooks from its official hook repository: the linter and the formatter.
- Configuration in one committed file, `ruff.toml`, at the repository root. Use ruff's defaults and additionally select the complexity and function-size rules (`C901`, `PLR0912`, `PLR0915`) at their default thresholds. Do not tune a threshold in this issue.
- `ruff.toml` is a new top-level file: add it to `build_ignore` in `galaxy.yml`.
- **`shellcheck`** as a pre-commit hook (the `shellcheck-py` hook, so no system package is needed), at its default severity, with no `.shellcheckrc` unless a finding requires one.
- Both run in CI through the existing Lint job, which already runs the pre-commit hooks. No new workflow and no new script.
## Fix what they find
- Format the existing Python with `ruff format` in its own commit, separate from any hand edits, so the diff is reviewable.
- Fix lint findings where the fix is small and safe.
- Where a finding is not worth fixing now, suppress it inline with the rule code and a reason (`# noqa: C901 reason`, `# shellcheck disable=SC… reason`). No global ignore of a rule.
- `scripts/check_image_versions.py`, `scripts/bump_image_versions.py` and `scripts/check_bot_pr_diff.py` may be removed or rewritten by #96. Do not restructure them here. If one needs more than a handful of complexity suppressions, use a per-file entry for that file in `ruff.toml` with a comment naming #96, and list it in the pull request.
## Notes
- `.pre-commit-config.yaml` is an image input: this is the two-PR loop. The first pull request carries the hook change and the PATCH bump of the `ci` image version (`scripts/bump_image_versions.py`); the consumer pins move in a second pull request after the image is built on `main`.
- Each pushed image layer must stay under 100 MB. The new hook environments are baked into the `ci` image; check the layer sizes the build prints.
- Renovate already follows hook `rev:` lines, so the new hooks need no Renovate change. `renovate.json` is not touched.
- No changelog fragment: nothing a consumer installs changes.
- The existing script tests under `tests/scripts/` must still pass after formatting and fixes.
## Not in this issue
- A check for comment length or file length: decided against in #91 (no standard tool, no custom checker).
- ansible-lint's `complexity` rule: #93 sets its number.
- Writing the code-style document: waits for #103.
## Acceptance
- `pre-commit run --all-files` passes locally with the new hooks, and the Lint check passes on the pull request.
- A deliberately bad change (an unused import in a script, an unquoted variable in `dev-setup.sh`) makes the corresponding hook fail; say in the pull request that this was tried.
- Every suppression carries a rule code and a reason.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Decided in #91 (part of the map #87). No hook or CI job lints the Python or shell in this repository today: about 1,260 lines under
scripts/andtests/scripts/plusscripts/dev-setup.share held by review alone. This issue adds the two standard tools as controls. It depends on no other open decision.Add
ruffas pre-commit hooks from its official hook repository: the linter and the formatter.ruff.toml, at the repository root. Use ruff's defaults and additionally select the complexity and function-size rules (C901,PLR0912,PLR0915) at their default thresholds. Do not tune a threshold in this issue.ruff.tomlis a new top-level file: add it tobuild_ignoreingalaxy.yml.shellcheckas a pre-commit hook (theshellcheck-pyhook, so no system package is needed), at its default severity, with no.shellcheckrcunless a finding requires one.Fix what they find
ruff formatin its own commit, separate from any hand edits, so the diff is reviewable.# noqa: C901 reason,# shellcheck disable=SC… reason). No global ignore of a rule.scripts/check_image_versions.py,scripts/bump_image_versions.pyandscripts/check_bot_pr_diff.pymay be removed or rewritten by #96. Do not restructure them here. If one needs more than a handful of complexity suppressions, use a per-file entry for that file inruff.tomlwith a comment naming #96, and list it in the pull request.Notes
.pre-commit-config.yamlis an image input: this is the two-PR loop. The first pull request carries the hook change and the PATCH bump of theciimage version (scripts/bump_image_versions.py); the consumer pins move in a second pull request after the image is built onmain.ciimage; check the layer sizes the build prints.rev:lines, so the new hooks need no Renovate change.renovate.jsonis not touched.tests/scripts/must still pass after formatting and fixes.Not in this issue
complexityrule: #93 sets its number.Acceptance
pre-commit run --all-filespasses locally with the new hooks, and the Lint check passes on the pull request.dev-setup.sh) makes the corresponding hook fail; say in the pull request that this was tried.