Skip to content

refactor(cli): remove the _prepare_cmd alias and ban noqa F401 in src - #3110

Merged
dan-petty merged 3 commits into
mainfrom
refactor/2166-the-unused-run-subprocess-re-import
Nov 2, 2026
Merged

dan-petty merged 3 commits into
mainfrom
refactor/2166-the-unused-run-subprocess-re-import

Conversation

@devops-cli-service

@devops-cli-service devops-cli-service Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

What

  • Remove the private alias _prepare_cmd = prepare_tool_cmd from src/devops_cli/core/process.py. The shared process fake and tests/core/test_process.py now use the public prepare_tool_cmd.
  • Set the ceiling src noqa: F401 of the suppression ratchet to 0 in tests/invariants/test_architectural_invariants.py.
  • Archive the OpenSpec change 2166-the-unused-run-subprocess-re-import.

Why

docs/TESTING.md says that no test imports a private name from devops_cli. The alias existed only for the fake and one test. The ratchet for # noqa: F401 in src/ had a ceiling of 15, but the real count is 0. So 15 new unused re-imports could enter src/ with no failure.

The re-import of run_subprocess in src/devops_cli/security/ruff.py is already gone on main. Commit a195069 removed it, so this change needs no work for it.

Proof

  • git grep -n "noqa: F401" -- src prints nothing. uv run ruff check --select F401 --ignore-noqa src prints All checks passed!.
  • git grep -n "_prepare_cmd" -- src tests prints lines only in tests/fixtures/roadmap_eval/. Those files are recorded eval data. No code uses the name.
  • The probe import import os # noqa: F401 in a new file under src/ passes the ratchet at ceiling 15 and fails it at ceiling 0 with src noqa: F401: 1 > ceiling 0. The output is in the comment on this pull request.
  • uv run devops ci test on the invariants test and the three process tests: 156 passed. uv run mypy --strict src/devops_cli/core/process.py passes.

Difference from the issue

The issue asks for a new devops ci row that runs ruff check --select F401 --ignore-noqa over src/. This change uses the suppression ratchet at ceiling 0 instead, and adds no row:

  • A plain unused import already fails the lint row, because the ruff selection holds F (ruff check on a file with import os exits 1 with unused-import).
  • The one way past that row is a # noqa: F401 marker. The ratchet counts those markers in src/ and now fails on the first one (src noqa: F401: 1 > ceiling 0, shown in the comment of this pull request).
  • A second row would run the same check again and add run time to the test job, which AGENTS.md rule 5 bounds.

The owner confirms this swap before the merge; criterion 3 of the issue changes with it.

Closes #2166

@dan-petty

Copy link
Copy Markdown
Owner

Probe for tasks 2.1 to 2.4. The probe file src/devops_cli/f401_probe.py holds the one line import os # noqa: F401. It was deleted after each run. Run on the merged tree (origin/main at d5dc921 merged in).

2.1 Count on the merged tree:

$ git grep -n "noqa: F401" -- src
(no output)
$ uv run ruff check --select F401 --ignore-noqa src
All checks passed!

2.2 Base, ceiling "src noqa: F401": 15, probe file present. Ruff sees the import. The ratchet does not fail. This is the gap.

$ uv run ruff check --select F401 --ignore-noqa src
  - import os  # noqa: F401
Found 1 error.
$ uv run devops ci test tests/invariants/test_architectural_invariants.py -k suppressions_stay_under_their_ceilings
tests/invariants/test_architectural_invariants.py .   [100%]
1 passed, 101 deselected in 1.10s

2.4 New ceiling "src noqa: F401": 0, probe file present. The ratchet fails.

$ uv run devops ci test tests/invariants/test_architectural_invariants.py -k suppressions_stay_under_their_ceilings
FAILED tests/invariants/test_architectural_invariants.py::test_suppressions_stay_under_their_ceilings
AssertionError: src noqa: F401: 1 > ceiling 0 in ['src/devops_cli/f401_probe.py'].
1 failed, 101 deselected in 1.15s

After the probe file was deleted:

$ git status --short
(no output)
$ uv run devops ci test tests/invariants/test_architectural_invariants.py
102 passed in 26.98s

The issue target (the run_subprocess re-import in src/devops_cli/security/ruff.py) is already gone on main: grep -n "run_subprocess\|noqa" src/devops_cli/security/ruff.py prints nothing.

Group 2 of the plan is done. A probe import with a noqa F401 passes the
ratchet at ceiling 15 and fails it at ceiling 0. Archive the change.
@dan-petty dan-petty changed the title refactor(security): the unused run_subprocess re-import in security/ruff.py... refactor(core): remove the _prepare_cmd alias and ban noqa F401 in src Nov 2, 2026
@dan-petty dan-petty changed the title refactor(core): remove the _prepare_cmd alias and ban noqa F401 in src refactor(cli): remove the _prepare_cmd alias and ban noqa F401 in src Nov 2, 2026
@dan-petty

Copy link
Copy Markdown
Owner

Advisory pre-merge review (automated; a person decides).

Recommendation: hold. The code change is correct, but the PR closes #2166 with one named criterion met in a different form, and no person has confirmed that form.

Findings

Severity Where Problem Evidence Fix
major PR body (Closes #2166); archived proposal.md, Acceptance, bullet 3 Issue #2166 criterion 3 asks for a devops ci row that runs ruff check --select F401 --ignore-noqa over src/. The PR adds no such row. It only sets the existing ratchet ceiling to 0. The plan says "Pending a person: confirm that the ratchet at 0 meets the criterion, or ask for the extra ruff --ignore-noqa row." No person has confirmed. The PR body does not say that the row was replaced. git grep -n "ignore-noqa" -- src .github pyproject.toml prints nothing at head e59c5c9. The diff changes no CI row. proposal.md line 23 holds the "Pending a person" text. A person confirms the substitution (or waives the row), and the PR body states it. Or add the row. Do not close #2166 before that.
minor tests/fixtures/roadmap_eval/stage/2166-.../ and the archived tasks.md task 1.3 The literal criterion 2 of the issue (rg -n "_prepare_cmd" src tests prints nothing) is not met. 7 lines remain in recorded eval data. These files exist on origin/main already. The PR body says so, but the plan files do not. git grep -n "_prepare_cmd" -- src tests lists only these fixture files. With ':!tests/fixtures' it prints 0 lines. Add one sentence in the PR body that the fixture hits are recorded data and out of scope. Do not edit the fixtures.
nit Archived proposal.md, Acceptance bullet 3 After the merge, "Pending a person" reads as an open question (AGENTS.md rule 8: write as merged). Same line as the major finding. Resolve it with the person's answer before the archive step, or keep it and accept the wording.

Dropped or confirmed as no defect

  • Criterion 1 (security/ruff.py re-import): no change is needed. The re-import is already gone on main. git grep -n "noqa: F401" -- src prints nothing.
  • Correctness: no defect. The deleted line was a plain alias of prepare_tool_cmd. The three real callers use the public name. The fake now imports it at the top of the file. Same function, same behavior.
  • Tests: none removed, skipped or loosened. The ceiling moved from 15 to 0, which is stricter. The count in src is 0, so the check passes. No fail-to-pass run is needed, because the PR is a refactor with no behavior change.
  • The standards lens found the title, scope, body and archive in order. Generated docs are in sync.

Checks that were run

  • git diff origin/main...HEAD read in full: 4 renames into the archive, 4 files in src and tests, and tick marks in tasks.md.
  • git grep for _prepare_cmd, noqa: F401 and ignore-noqa at head.
  • ruff check --select F401 --ignore-noqa src: "All checks passed!". ruff on the 4 changed Python files: pass.
  • uv run devops ci test on tests/core/test_process.py, test_process_contract.py, test_process_hardening.py, tests/invariants/test_architectural_invariants.py and tests/commands/test_ci.py: 280 passed.
  • mypy --strict on core/process.py: no error. The test-file errors are not on changed lines.
  • devops docs generate --sync-readme in the review worktree: no diff.
  • PR checks at about 03:38 UTC: all finished checks passed. Tests & Coverage was still running. Look at its result and its duration before the draft is marked ready.

Not run: the full suite of about 128 files that use the process fake. CI covers it.

@dan-petty
dan-petty marked this pull request as ready for review November 2, 2026 04:27
@dan-petty
dan-petty self-requested a review as a code owner November 2, 2026 04:27
@dan-petty
dan-petty merged commit e40dbac into main Nov 2, 2026
23 of 24 checks passed
@dan-petty
dan-petty deleted the refactor/2166-the-unused-run-subprocess-re-import branch November 2, 2026 04:28
dan-petty pushed a commit that referenced this pull request Nov 2, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.40.0](v0.39.1...v0.40.0)
(2026-11-02)


### Features

* **k8s:** serve deepseek-v4.1-flash-1017 via OpenRouter
([#3145](#3145))
([d5dc921](d5dc921)),
closes [#3144](#3144)


### Bug Fixes

* **cli:** stop with one error line in a removed working directory
([#3133](#3133))
([c4a4dbb](c4a4dbb))


### Code Refactoring

* **cli:** remove the _prepare_cmd alias and ban noqa F401 in src
([#3110](#3110))
([e40dbac](e40dbac))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant