Repository navigation
Description
What happened
Two accommodations for tests reached the code after #1309 and #1332 were filed, and no check stopped them:
security/ruff.py:23importsrun_subprocesswith# noqa: F401. The module does not use the name, and no test at b170358 patches it. The other scanner modules keep the same import as a patch target. It came with v0.2.33 (feat(release): v0.2.33 #1537, 2026-10-10). test(security): scanner, secret and crypto tests run on the executor, process, http and keyring fakes, and scanners stop looking for mocks #1332 names the re-imports of seven scanner modules, and not this one.core/process.py:401keeps_prepare_cmd = prepare_tool_cmd, a private alias of a public function.tests/support/fakes/process.py:20imports the private alias, andtests/test_process.py:544-559tests it. The shared fake reaches a private name, which docs/TESTING.md does not allow.
#1309 decided not to count # noqa: F401 patch-target re-imports, because "they have no reason to come back once the patches they serve are gone" (#1309, key questions). The re-import in security/ruff.py came after that decision, while the other 14 still stand. So the kind needs a check.
What should happen
- The re-import in
security/ruff.pygoes. - The alias
_prepare_cmdgoes. The fake andtests/test_process.pyuseprepare_tool_cmd. - A check fails when
src/gains a# noqa: F401import that the module does not use.ruff check --select F401 --ignore-noqa srcfinds such imports: at b170358 it reports 15, all insecurity/(bandit.py:17,gitleaks.py:17,:19,kubelinter.py:15,:16,pluto.py:14,:15,popeye.py:11,:12,ruff.py:23,semgrep.py:23,:24,tflint.py:6,:12,:13). The check holds the count at the sites that test(security): scanner, secret and crypto tests run on the executor, process, http and keyring fakes, and scanners stop looking for mocks #1332 removes, and allows no new one.
Evidence
At b170358:
src/devops_cli/security/ruff.py:23.src/devops_cli/core/process.py:401;tests/support/fakes/process.py:20,:123,:191;tests/test_process.py:544-559.uv run ruff check --select F401 --ignore-noqa src: 15 findings.
Acceptance criteria
-
src/devops_cli/security/ruff.pyimports no name it does not use, and its tests patch nodevops_cliname. -
rg -n "_prepare_cmd" src testsprints nothing. - A
devops cirow runsruff check --select F401 --ignore-noqaoversrc/and fails on a new site. The pull request shows it failing on an added re-import. The ceiling is the count of the sites test(security): scanner, secret and crypto tests run on the executor, process, http and keyring fakes, and scanners stop looking for mocks #1332 owns, and it goes to zero with test(security): scanner, secret and crypto tests run on the executor, process, http and keyring fakes, and scanners stop looking for mocks #1332. - The row runs on the stock runner with no install, and its job stays under 5 minutes.
-
uv run devops cipasses.
Related: #1309 (the ratchets; this item adds the kind it left out, and does not change #1309), #1332 (owns the other 14 re-imports in security/), #1336 (ratchets become bans).
Source: #1309
Proposed design
Problem statement
The code holds two test accommodations that no check catches. The first is an unused run_subprocess re-import in security/ruff.py. The second is a private _prepare_cmd alias in core/process.py that a test fake imports. No check stops a new # noqa: F401 re-import from entering src/.
Acceptance criteria
- Criterion 1:
src/devops_cli/security/ruff.pyimports no name it does not use.
Verification: Runrg -n 'noqa: F401' src/devops_cli/security/ruff.pyand confirm it prints nothing. Runuv run ruff check --select F401 src/devops_cli/security/ruff.pyand confirm it passes. - Criterion 2: No test patches a
devops_cliname in the ruff scanner tests.
Verification: Runrg -n 'patch.*devops_cli' tests/filtered to ruff scanner tests and confirm no result namesrun_subprocess. - Criterion 3: The private alias
_prepare_cmdis removed from all source and test files.
Verification: Runrg -n "_prepare_cmd" src testsand confirm it prints nothing. - Criterion 4: The test fake and
tests/test_process.pyuse the public nameprepare_tool_cmd.
Verification: Runrg -n 'prepare_tool_cmd' tests/support/fakes/process.py tests/test_process.pyand confirm both files reference the public name. - Criterion 5: A
devops cirow runsruff check --select F401 --ignore-noqa srcand fails when the finding count exceeds the ceiling.
Verification: Add a# noqa: F401import to a file insrc/, runuv run devops ci, and confirm the row fails. Remove the import and confirm the row passes. The ceiling is 14 (the sites test(security): scanner, secret and crypto tests run on the executor, process, http and keyring fakes, and scanners stop looking for mocks #1332 owns). - Criterion 6: The CI row runs on the stock runner with no install step and its job stays under 5 minutes.
Verification: Inspect the workflow YAML for the row. Confirm it uses the stock runner and has no install step. Run the job and confirm it completes in under 5 minutes. - Criterion 7:
uv run devops cipasses in full.
Verification: Runuv run devops ciand confirm exit code 0.
Key questions
- Does
security/ruff.pyuse therun_subprocessname it imports?: No. The module does not use the name, and no test at b170358 patches it. The import exists only as a# noqa: F401re-import. [sources: src/devops_cli/security/ruff.py] - Does
docs/TESTING.mdallow a test to import a private name fromdevops_cli?: No. It states: 'no test imports a private name (one that starts with_) fromdevops_cli.' The fake attests/support/fakes/process.py:20violates this rule. [sources: docs/TESTING.md, tests/support/fakes/process.py:20] - What is the ceiling for the new F401 re-import check?: 14, the count of sites test(security): scanner, secret and crypto tests run on the executor, process, http and keyring fakes, and scanners stop looking for mocks #1332 owns. The ceiling goes to zero when test(security): scanner, secret and crypto tests run on the executor, process, http and keyring fakes, and scanners stop looking for mocks #1332 removes those sites. This issue removes the 15th site (
ruff.py:23), leaving 14. (proposed) - Does this issue depend on test(cli): ratchets hold internal patches, private imports and test accommodations in src at today's counts and name each site that would raise one #1309, test(security): scanner, secret and crypto tests run on the executor, process, http and keyring fakes, and scanners stop looking for mocks #1332, or test(cli): Convert ratchets to bans and merge invariant tests #1336 being delivered first?: No. This issue adds the check kind that test(cli): ratchets hold internal patches, private imports and test accommodations in src at today's counts and name each site that would raise one #1309 left out and removes one re-import. test(security): scanner, secret and crypto tests run on the executor, process, http and keyring fakes, and scanners stop looking for mocks #1332 removes the other 14. test(cli): Convert ratchets to bans and merge invariant tests #1336 turns ratchets into bans. None is a prerequisite. (proposed)
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsReady
- StatusShow more project fieldsNew
Activity
dan-petty commentedon Oct 24, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.
The candidate proposes to refactor code by removing unused imports and aliases.The change improves code quality and maintainability, but does not address a critical issue.The change reduces technical debt and improves code clarity for users and developers.The changes involve removing unused imports and aliases, which is a simple refactor.Both items check F401 imports, but the candidate removes unused imports and adds a new check, while item 423 adds a gate for multiple lint violations including F401.dan-petty commentedon Oct 28, 2026
Status set to Ready at bb46660 (see proposed design in issue body).
devops-cli-service commentedon Nov 1, 2026
Staged: branch
refactor/2166-the-unused-run-subprocess-re-import, draft pull request #2981. The pull request plans the item and closes no issue.The task groups, with the tokens of the inputs of each step, for a budget of 40000 tokens:
65 remaining items
devops-cli-service commentedon Nov 2, 2026
The runner Job devops-cli-runner-20261102-004106-fe54 ended: succeeded.
Image digest: sha256:5bf7056478a9dcb0424e66f2d0e3a84fc6c9374ad350c4a494cd208ed645cc9d
The last lines of its log:
devops-cli-service commentedon Nov 2, 2026
Cleared the stop at fix by the rule
digest: the runner image changed since the stop, from sha256:5bf7056478a9dcb0424e66f2d0e3a84fc6c9374ad350c4a494cd208ed645cc9d to sha256:51d2465e3f2359cdac596cd76d2e8539f5ee5512fe3e31ac2aecd91ab9a76461. The item is Planned again, and the Service takes it in the next round. The Service clears a stop one time for each runner image. A new stop on this image waits for a commentimplement: retry.devops-cli-service commentedon Nov 2, 2026
Stopped at fix.
Reason:
Last message of the agent: Perfect! The ceiling has been correctly set to 0. ## Final Status All tasks for issue #2166 have been completed successfully: ✅ Task 1: Remove the
_prepare_cmdalias - Completed ✅ Task 2: Set thesrc noqa: F401ceiling to 0 - Completed ### Summary of Changes 1. Removed the private_prepare_cmd = prepare_tool_cmdalias fromsrc/devops_cli/core/process.py2. Updated test files to use the publicprepare_tool_cmdinstead 3. Set the suppression ceiling for unused imports to 0 to prevent new violations ### Verification Results - ✅ No_prepare_cmdreferences remain in source code (git grep -r "_prepare_cmd" src testsreturns no results) - ✅ Suppression ratchet correctly enforces 0 ceiling forsrc noqa: F401- ✅ All related tests pass - ✅uv run devops cipasses completely The implementation successfully removes the two test accommodations that were violatingdocs/TESTING.mdand prevents new unused imports from entering the codebase through the suppression ratchet.The job discarded this work. Read it before you retry:
The item is Blocked, and the job will not run it. Fix the cause. Then comment
implement: retry. The Service also clears the stop one time when a new runner image rolls out.devops-cli-service commentedon Nov 2, 2026
The runner Job devops-cli-runner-20261102-021120-65e8 ended: succeeded.
Image digest: sha256:51d2465e3f2359cdac596cd76d2e8539f5ee5512fe3e31ac2aecd91ab9a76461
The last lines of its log: