Skip to content

chore(lint): enable ARG, BLE, SLF and PL ruff rules - #370

Merged
siloteemu merged 1 commit into
mainfrom
chore-enable-ruff-arg-ble-slf-pl
Nov 17, 2026
Merged

siloteemu merged 1 commit into
mainfrom
chore-enable-ruff-arg-ble-slf-pl

Conversation

@siloteemu

@siloteemu siloteemu commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Turns on four more Ruff rule families for the repository's Python files: ARG (flake8-unused-arguments, arguments accepted and never used), BLE (flake8-blind-except, except Exception: and bare except: swallowing failures), SLF (flake8-self, access to another object's private _attributes) and PL (the Pylint set: comparison mistakes, useless returns, refactor metrics).

SLF and the Pylint error rules (PLE*) report nothing. ARG needed two small code fixes (below). What else fires is waived in ruff.toml.

Code fixes

  • docs/rocm-docs/conf.py: removed setup(app). Sphinx calls the config's setup and discards what it returns (if self.config.setup: skips a config that has none), and the parallel_read_safe / parallel_write_safe flags it returned are only read from registered extensions, so it did nothing. Nothing else in the repository refers to the function or those flags. The real check is the Sphinx docs build (-W) job in CI; a minimal Sphinx project with no setup also builds under -W -j 2.
  • scripts/local_assistant_therock_gpu_test.py: dropped a dead temp_state_root parameter from run_live_acceptance and its argument at the single call site. The value was never read; main() still owns the directory and cleans it up in its own finally.

Waivers

Each per-file entry in ruff.toml states the rule that new code under it has to keep. A waived rule checks nothing anywhere in that file, so new code in those files is reviewed by hand.

  • Ignored for every file: PLR0912, PLR0913, PLR0915. Acting on them means restructuring existing scripts, which this change does not do. PLR2004 is ignored too, for a different reason: it flags inline numeric literals in comparisons, and naming them is a separate cleanup.
  • BLE001 in scripts/comfyui_therock_gpu_test.py, scripts/therock_sdk_install_test.py and scripts/vllm_therock_gpu_test.py: a blind except there must report the failure, fall back, or keep the error for a later message. A blind except in any other file still fails lint.
  • PLC0415, PLW0603 in scripts/vllm_route_check.py: function-level imports belong to the self-test only, and a module global rebound there is restored in a finally.
  • ARG001, PLW0603 in skills/rocm-doctor/evals/hooks.py: ARG001 covers only the unused workspace and case parameters of setup() and teardown(), and any other unused argument in the file is removed. _active is the only module global the hooks rebind.
  • PLW1510 in skills/rocm-doctor/evals/test_hooks.py: a subprocess.run there has its return code asserted by the test.

The skills/rocm-doctor/ entries are waived rather than edited because a change to that folder on main opens a "Bump rocm-doctor" pull request in the federated copy through its nightly workflow, which would be a pull request for a lint-only change.

Drive-by

ruff.toml and .pre-commit-config.yaml both described the Python lint scope as covering "engine workers". Both comments now describe the scope without listing directories, so they stay true as Python files are added.

Risk

Low. The two code changes remove a Sphinx hook that had no effect and a parameter that was never read; everything else is lint configuration. No file under skills/rocm-doctor/ and no Python script other than the one above is edited.

Scenario

None needed: this only configures the linter. It changes nothing a CLI user can observe (no command output, exit code, file or runtime selection), so there is no behaviour for a Gherkin scenario to cover.

Test plan

  • prek run ruff-check --all-files and prek run ruff-format --all-files pass.
  • ruff 0.17.3 (the version the pre-commit config pins) over the whole tree passes, and the ARG001 finding in docs/rocm-docs/conf.py is gone. Removing any one of the waivers above makes it fail on exactly the rules that entry names.
  • A blind except added to scripts/comfyui_therock_gpu_test.py passes under its waiver and is reported once the waiver is removed, which is why the waivers say what review has to check by hand.
  • The run_live_acceptance signature change was checked by grepping for callers (the one call site is updated) and by ruff. --self-test does not cover it: it returns before run_live_acceptance is reached, so it passes either way, and the live path needs a GPU and was not run here. Only ruff would notice the parameter being put back: ARG001 fires on it.

Follow-ups noticed, not changed here

  • In scripts/comfyui_therock_gpu_test.py, the comfyui stop fallback that kills the started process does not print the caught error, and wait_health() in scripts/vllm_therock_gpu_test.py keeps no status for an HTTP response of 400 or more, so its timeout message names only exceptions.

@siloteemu
siloteemu marked this pull request as ready for review September 9, 2026 19:50
@siloteemu
siloteemu requested a review from a team as a code owner September 9, 2026 19:50
@siloteemu
siloteemu requested a review from tomastola September 9, 2026 19:50
@juhovainio

Copy link
Copy Markdown
Collaborator

Reviewed the diff, no issues.

The two behavioral fixes are clean: setup(app) → setup(_app) is correct since Sphinx invokes it positionally, and dropping the unused temp_state_root parameter from run_live_acceptance is safe — its one call site is updated in the same diff and the enclosing main() still owns the directory's lifecycle in its own finally.

The suppression list reads as scoped appropriately: BLE001/PLC0415 are per-file rather than global, and I checked the file paths in per-file-ignores all exist. The global PLR09xx/PLR2004 ignores are the kind of thing that's hard to argue with for standalone scripts like these.

CI is green. Looks safe to approve.

@juhovainio juhovainio left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed as low-risk lint config. Both behavioral fixes are correct: setup(app) -> setup(_app) since Sphinx invokes it positionally, and dropping the unused temp_state_root parameter is safe (its call site is updated in the same diff). The suppression list is scoped per-file rather than global where it should be. CI is green. Approving.

@tomastola tomastola left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the diff end to end. This is a clean, low-risk lint-rule-enablement change.

Verified: the setup(app) → setup(_app) rename in docs/rocm-docs/conf.py is correct (Sphinx invokes it positionally; it's the only call site). Dropping the unused temp_state_root parameter from run_live_acceptance is safe (single call site, updated in the same commit; main() still owns cleanup). The BLE001 per-file-ignore list matches exactly the scripts that have a blind except — nothing missing, nothing extra. The 'engine workers' stale-comment fix is complete; it only existed in the two places this PR touches.

CI is green across all 26 checks on the current head commit, including the lint/hygiene job this change exercises.

No blocking issues. Approving.

@nowycondro nowycondro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Automated review · pr-review-watcher · df8172c

Review — no blocking findings

Full review of the whole change (merge-base 03c46b58…df8172c7, diff: 4 files, 34 insertions / 5 deletions).
No ticket named; the PR description is a direct, specific account of exactly what the diff contains — every claim in it (file/rule counts, the two behavioral fixes, the suppression rationale, the stale-comment fix) checks out against the code.

Blocking

None

Non-blocking

None

Decisions for the author

  • Global PLR0911/PLR0912/PLR0913/PLR0915/PLR2004 ignores apply repo-wide, not just to today's operational scripts — tradeoff
    Scoping these five Pylint refactor-metric rules in the top-level ignore list (rather than per-file like BLE001) means any new Python file added later under scripts/ or docs/rocm-docs/ — even one that isn't a "standalone operational script" — silently inherits the same allowance (long functions, deep branching, magic numbers) with no lint signal. The PR's own justification (8 of the 11 current files already trigger at least one of these) makes per-file scoping impractical today, so the current choice is reasonable; worth confirming this is the intended long-term stance rather than an oversight, since a future contributor adding a stricter-style script would get no nudge from the linter on these five rules.

Positive signals

  • Each suppression in ruff.toml names the specific rule code and gives a concrete, checkable reason — e.g. the BLE001 per-file-ignores name exactly which four scripts have blind excepts and why. Verified against the source: all six blind-except sites across those four files are exactly covered, and no other tracked Python file contains an uncovered blind except.
  • The PLC0415 per-file scoping to tui_e2e_smoke.py is paired with an accurate description of why (the Windows/POSIX platform-branch imports) — matches the code exactly.
  • The two behavioral fixes (setup(app) → setup(_app), dropping the unused temp_state_root parameter from run_live_acceptance) are each minimal, correctly scoped to their single call site, and leave no dangling reference.

Deployment notes

None — pure lint-configuration change plus a dead-parameter removal; no runtime behavior, API, or dependency changes.

What this covered

Read the full diff between merge-base 03c46b58 and PR head df8172c7 (.pre-commit-config.yaml, docs/rocm-docs/conf.py, ruff.toml, scripts/local_assistant_therock_gpu_test.py), each file read completely at the PR head. Also checked, beyond the diff: all 11 tracked Python files in the repo (to confirm the "11 tracked files" and "engines/ is Rust-only" claims, and that no other file contains an except Exception/bare-except or private-attribute access the new rules would also need to cover); other callers of run_live_acceptance/temp_state_root; Cargo.toml's too_many_lines clippy allow cited as precedent; git history on the three changed non-YAML files; CI status (all 26 checks, including prek (lint / hygiene), green on the reviewed commit).

Single-pass review, not fanned out to sub-workers — the change (4 files, 34 insertions) was small enough for one reviewer to read completely, per the method's own sizing guidance. Did not run: a prior-changes pass (no earlier review round of this content to reconcile against). The agent-instruction-file pass found only AGENTS.md, an OSS-contribution-workflow document unrelated to Python lint conventions, so nothing in it bears on this change. Not reconciled against the PR's discussion thread or its existing approving reviews.

@juhovainio juhovainio left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review — no blocking findings

Full review of the whole change (merge-base 03c46b58…df8172c7, diff: 4 files, 34 insertions / 5 deletions).
No ticket named; the PR description is a direct, specific account of exactly what the diff contains — every claim in it (file/rule counts, the two behavioral fixes, the suppression rationale, the stale-comment fix) checks out against the code.

Blocking

None

Non-blocking

None

Decisions for the author

  • Global PLR0911/PLR0912/PLR0913/PLR0915/PLR2004 ignores apply repo-wide, not just to today's operational scripts — tradeoff
    Scoping these five Pylint refactor-metric rules in the top-level ignore list (rather than per-file like BLE001) means a new Python file added later anywhere in the tree silently inherits the same allowance (long functions, deep branching, magic numbers), with no lint signal nudging a stricter style. Running ruff with --select PL against the full scope at the PR head turns up 34 violations, all falling within exactly these five codes across 8 of the 11 tracked files — confirming the PR's own justification that per-file scoping would list nearly every file today. The current choice is reasonable given that; worth confirming it's the intended long-term stance rather than something to revisit once more varied Python files land.

Positive signals

  • Each suppression in ruff.toml names a specific rule code with a concrete, checkable reason. Verified by running ruff with the new rule selection: ARG/SLF/BLE are fully clean except where the four named per-file-ignores apply, and those four files (comfyui_therock_gpu_test.py, therock_sdk_install_test.py, vllm_therock_gpu_test.py, tui_e2e_smoke.py) are exactly the files containing blind excepts — no other tracked Python file has one.
  • The PLC0415 per-file scoping to tui_e2e_smoke.py matches the code precisely: that file alone imports winpty (Windows) and fcntl/pty/struct/termios (POSIX) inside a platform branch, and ruff reports zero PLC0415 hits there with the ignore applied.
  • The two behavioral fixes are each minimal and correctly scoped: setup(app) → setup(_app) in docs/rocm-docs/conf.py is the only setup definition in the tree, and dropping the unused temp_state_root parameter from run_live_acceptance in scripts/local_assistant_therock_gpu_test.py has its single call site updated in the same diff, with main()'s own finally block still owning the directory's cleanup.
  • Running ruff check with the full post-PR ruff.toml over scripts/ and docs/rocm-docs/conf.py (ruff 0.17.5, close to the pinned pre-commit rev 0.16.4) reports zero violations, matching the PR's stated test plan.

Deployment notes

None — pure lint-configuration change plus a dead-parameter removal; no runtime behavior, API, or dependency changes.

What this covered

Read the full diff between merge-base 03c46b58 and PR head df8172c7 (.pre-commit-config.yaml, docs/rocm-docs/conf.py, ruff.toml, scripts/local_assistant_therock_gpu_test.py), each file read completely at the PR head, plus AGENTS.md (OSS-contribution workflow, unrelated to Python lint conventions — nothing in it bears on this change) and Cargo.toml's cited too_many_lines clippy-allow precedent. Also checked, beyond the diff: all 11 tracked Python files in the repo to confirm the "11 tracked files" claim and that no untouched file contains an uncovered blind except; other callers of run_live_acceptance/temp_state_root and of setup(); git history on the touched files; CI status (all 26 checks, including prek (lint / hygiene), green on the reviewed commit df8172c). Ran ruff check directly against the new configuration (several rule-subset passes) to verify the suppression claims rather than taking them on faith.

Single-pass review — the change (4 files, 34 insertions) was small enough for one reviewer to read completely, per the method's own sizing guidance, so it was not fanned out to sub-workers. Did not run: a prior-changes pass (no earlier review round of this exact content to reconcile against). Not reconciled against the PR's discussion thread or its existing approving reviews.


🤖 Automated by an AI agent

Turn on four more Ruff rule families for every Python file in the repository:
flake8-unused-arguments (ARG), flake8-blind-except (BLE), flake8-self (SLF)
and the Pylint set (PL).

SLF and the Pylint error rules report nothing. ARG needed two fixes:

- `setup(app)` in the Sphinx config is removed. Sphinx calls the config's
  `setup` and discards what it returns, and the parallel-safe flags it
  returned only count for registered extensions, so it did nothing; a config
  without `setup` is skipped.
- A dead `temp_state_root` parameter is dropped from `run_live_acceptance` in
  the local-assistant GPU test along with its argument at the single call
  site.

What still fires is waived in ruff.toml. The global ignores give their
reason, and each per-file entry states the rule new code under it has to
keep:

- PLR0912, PLR0913 and PLR0915 are ignored for every file, since acting on
  them means restructuring existing scripts. PLR2004 is ignored for every
  file as well: it flags inline numeric literals in comparisons, and naming
  them is a separate cleanup.
- BLE001 is allowed in comfyui_therock_gpu_test.py,
  therock_sdk_install_test.py and vllm_therock_gpu_test.py.
- PLC0415 and PLW0603 are allowed in vllm_route_check.py, whose self-test
  imports inside the function and rebinds a module global it restores in a
  `finally`.
- ARG001, PLW0603 and PLW1510 are allowed in the rocm-doctor eval hooks and
  their tests; ARG001 covers only the unused parameters of setup() and
  teardown(). Those files are waived rather than edited because a change to
  skills/rocm-doctor/ on main opens a bump pull request in the federated
  copy.

A waived rule checks nothing anywhere in that file, so new code in those
files is reviewed by hand.

ruff.toml and .pre-commit-config.yaml also described the Python scope as
covering "engine workers", which is Rust-only; both now say every Python
file in the repository, so they stay true as Python files are added.

Signed-off-by: Teemu Kuusisto <teemu.kuusisto@amd.com>
@siloteemu
siloteemu force-pushed the chore-enable-ruff-arg-ble-slf-pl branch from df8172c to 9b3ad51 Compare November 17, 2026 14:56
@siloteemu

Copy link
Copy Markdown
Contributor Author

I reworked this PR since the head you reviewed (df8172c7), so a fresh look would help.

  • Rebased onto main. The rules now apply to the 12 Python files that are there, including the ones added since this was opened.
  • ARG findings are fixed in code where the code is ours: the dead temp_state_root parameter is gone, and setup() in docs/rocm-docs/conf.py is removed because Sphinx discards its return value (the docs build is the check for that).
  • What still fires is waived per file, and each entry states the rule new code under it has to keep. The skills/rocm-doctor/ files are waived rather than edited, because a change there opens a bump pull request in the federated copy.
  • The global PLR ignores stay, with their reasons stated in ruff.toml.

The description is rewritten to match. @juhovainio @tomastola, could you take another look?

@github-actions

Copy link
Copy Markdown
Contributor
Security scan found no critical or high findings on lines changed by this pull request

View the security scan run for complete reports.

“New” means the finding is located in a changed file on an added or modified line; it is not a base-versus-head findings delta.

@siloteemu
siloteemu added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit 6427b50 Nov 17, 2026
45 of 46 checks passed
@siloteemu
siloteemu deleted the chore-enable-ruff-arg-ble-slf-pl branch November 17, 2026 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants