Repository navigation
chore(lint): enable ARG, BLE, SLF and PL ruff rules - #370
Conversation
|
Reviewed the diff, no issues. The two behavioral fixes are clean: The suppression list reads as scoped appropriately: CI is green. Looks safe to approve. |
juhovainio
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
🔴 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/PLR2004ignores apply repo-wide, not just to today's operational scripts — tradeoff
Scoping these five Pylint refactor-metric rules in the top-levelignorelist (rather than per-file likeBLE001) means any new Python file added later underscripts/ordocs/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.tomlnames the specific rule code and gives a concrete, checkable reason — e.g. theBLE001per-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
PLC0415per-file scoping totui_e2e_smoke.pyis 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 unusedtemp_state_rootparameter fromrun_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
left a comment
There was a problem hiding this comment.
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/PLR2004ignores apply repo-wide, not just to today's operational scripts — tradeoff
Scoping these five Pylint refactor-metric rules in the top-levelignorelist (rather than per-file likeBLE001) 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 PLagainst 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.tomlnames a specific rule code with a concrete, checkable reason. Verified by running ruff with the new rule selection:ARG/SLF/BLEare 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
PLC0415per-file scoping totui_e2e_smoke.pymatches the code precisely: that file alone importswinpty(Windows) andfcntl/pty/struct/termios(POSIX) inside a platform branch, and ruff reports zeroPLC0415hits there with the ignore applied. - The two behavioral fixes are each minimal and correctly scoped:
setup(app)→setup(_app)indocs/rocm-docs/conf.pyis the onlysetupdefinition in the tree, and dropping the unusedtemp_state_rootparameter fromrun_live_acceptanceinscripts/local_assistant_therock_gpu_test.pyhas its single call site updated in the same diff, withmain()'s ownfinallyblock still owning the directory's cleanup. - Running
ruff checkwith the full post-PRruff.tomloverscripts/anddocs/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>
df8172c to
9b3ad51
Compare
|
I reworked this PR since the head you reviewed (
The description is rewritten to match. @juhovainio @tomastola, could you take another look? |
Security scan found no critical or high findings on lines changed by this pull requestView 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. |
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 bareexcept:swallowing failures),SLF(flake8-self, access to another object's private_attributes) andPL(the Pylint set: comparison mistakes, useless returns, refactor metrics).SLFand the Pylint error rules (PLE*) report nothing.ARGneeded two small code fixes (below). What else fires is waived inruff.toml.Code fixes
docs/rocm-docs/conf.py: removedsetup(app). Sphinx calls the config'ssetupand discards what it returns (if self.config.setup:skips a config that has none), and theparallel_read_safe/parallel_write_safeflags 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 theSphinx docs build (-W)job in CI; a minimal Sphinx project with nosetupalso builds under-W -j 2.scripts/local_assistant_therock_gpu_test.py: dropped a deadtemp_state_rootparameter fromrun_live_acceptanceand its argument at the single call site. The value was never read;main()still owns the directory and cleans it up in its ownfinally.Waivers
Each per-file entry in
ruff.tomlstates 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.PLR0912,PLR0913,PLR0915. Acting on them means restructuring existing scripts, which this change does not do.PLR2004is ignored too, for a different reason: it flags inline numeric literals in comparisons, and naming them is a separate cleanup.BLE001inscripts/comfyui_therock_gpu_test.py,scripts/therock_sdk_install_test.pyandscripts/vllm_therock_gpu_test.py: a blindexceptthere must report the failure, fall back, or keep the error for a later message. A blindexceptin any other file still fails lint.PLC0415,PLW0603inscripts/vllm_route_check.py: function-level imports belong to the self-test only, and a module global rebound there is restored in afinally.ARG001,PLW0603inskills/rocm-doctor/evals/hooks.py:ARG001covers only the unusedworkspaceandcaseparameters ofsetup()andteardown(), and any other unused argument in the file is removed._activeis the only module global the hooks rebind.PLW1510inskills/rocm-doctor/evals/test_hooks.py: asubprocess.runthere has its return code asserted by the test.The
skills/rocm-doctor/entries are waived rather than edited because a change to that folder onmainopens a "Bumprocm-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.tomland.pre-commit-config.yamlboth 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-filesandprek run ruff-format --all-filespass.ruff0.17.3 (the version the pre-commit config pins) over the whole tree passes, and theARG001finding indocs/rocm-docs/conf.pyis gone. Removing any one of the waivers above makes it fail on exactly the rules that entry names.exceptadded toscripts/comfyui_therock_gpu_test.pypasses under its waiver and is reported once the waiver is removed, which is why the waivers say what review has to check by hand.run_live_acceptancesignature change was checked by grepping for callers (the one call site is updated) and by ruff.--self-testdoes not cover it: it returns beforerun_live_acceptanceis 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:ARG001fires on it.Follow-ups noticed, not changed here
scripts/comfyui_therock_gpu_test.py, thecomfyui stopfallback that kills the started process does not print the caught error, andwait_health()inscripts/vllm_therock_gpu_test.pykeeps no status for an HTTP response of 400 or more, so its timeout message names only exceptions.