Repository navigation
Description
Problem or Motivation
entry.main in src/devops_cli/entry.py calls set_dry_run(True) when the argv holds --dry-run. The root callback main in src/devops_cli/main.py then calls set_dry_run(requested) before any command runs. For every run that reaches a command, the root callback decides the final state, so the call in entry.main has no effect that a person or a test can see.
Found while the tests of the entry point moved off a mocked app (#3901). The old test saw the call only because it replaced the app with a mock. A mutation that removes the call survives all tests that run the real app.
The call may still serve a run that stops before the root callback, such as an eager option like --version. Check this first. If no such run needs the state, the call is dead code.
Proposed Solution & Architectural Design
Check the runs that stop before the root callback. If none needs the state, delete the call and the set_dry_run import from entry.py. If one needs it, add a test through the public interface that fails without the call.
Target Subsystem
SDLC, Git & PR Governance
Acceptance criteria
- The call is deleted with a test that shows no behavior changes, or a test through the public interface fails when the call is removed.
-
uv run devops cipasses.
Existing Tool Considered
Not applicable: this item builds nothing.
Related
Found in #3901. Parent of the test migration: #1333.
Alternatives check of 2026-11-09: not-applicable.
Class: refactor, no search.
Tool: none found.
Proposed design
Problem statement
entry.main in src/devops_cli/entry.py calls set_dry_run(True) when the argv holds --dry-run, and the root callback main in src/devops_cli/main.py sets the dry-run state again before any command runs. The check finds that no run that stops before the root callback (--version, --help, a usage error or a no-argument run) reads the state, and that the telemetry export at exit reads in_dry_run_invocation, which mark_dry_run_invocation already sets. The entry call is not harmless in one run: with DEVOPS_CLI_DRY_RUN exported and a command's own --dry-run, it marks the request as activated here, so the root callback clears the exported variable, contrary to the recorded intent. The change deletes the call and the set_dry_run import, keeps the invocation mark, and tests the early-stop runs and the exported-env run.
Acceptance criteria
Requirement: Entry point sets no dry-run state
The function entry.main SHALL NOT call set_dry_run and src/devops_cli/entry.py SHALL NOT import it, so that an exported DEVOPS_CLI_DRY_RUN survives a command's own --dry-run.
Scenario: An exported dry-run request meets a command's own flag
- WHEN the real entry point runs
main(["devops", "uv", "sync", "--dry-run"])withDEVOPS_CLI_DRY_RUN=1 - THEN the run prints the
devops uv syncplan, starts no program, andis_dry_run()is true
Requirement: Early stop runs keep their behavior
A run that stops before the root callback, such as --version, MUST keep its output and its exit code.
Scenario: Version flag with the dry-run flag
- WHEN the real entry point runs
main(["devops", "--dry-run", "--version"]) - THEN the output shows the version and the exit code is 0
Requirement: Dry-run invocation mark stays
The function entry.main SHALL keep the call to mark_dry_run_invocation with the requested value.
Scenario: The mark is recorded before an early stop
- WHEN the real entry point runs
main(["devops", "--dry-run", "--version"]) - THEN
in_dry_run_invocation()is true after the run, although the root callback never ran
Requirement: Full check passes
The command uv run devops ci MUST pass after the change.
Scenario: CI run on the change
- WHEN
uv run devops ciruns on the branch - THEN the command exits with code 0
Existing Tool Considered
Not applicable: this item builds nothing. It deletes one call and one import and adds tests to tests/commands/test_entry_point.py. The cost is a few thousand tokens and under one hour. The alternatives check of 2026-11-09 recorded verdict not-applicable (class refactor, no search) and found no tool.
Key questions
- Which runs stop before the root callback
mainand could need the dry-run state thatentry.mainsets?: None. The runs that stop before the root callback are--version,--help, a usage error and a run with no arguments. The--versioncallback prints the version and raisestyper.Exitwithout reading the state (src/devops_cli/main.py:268-273), and Typer prints help or a usage error without reaching it. The reads ofis_dry_run()before a command are in_delegate(src/devops_cli/main.py:158) and in the lazy proxy (src/devops_cli/core/cli.py:184), both after the root callback. The atexit handler prints only the elapsed time (src/devops_cli/main.py:27-35), and the telemetry export at exit asksin_dry_run_invocation()(src/devops_cli/telemetry/tracer.py:1328-1331), whichmark_dry_run_invocation(src/devops_cli/entry.py:50,src/devops_cli/dry_run/state.py:49-52) sets before the app runs, so an early stop still exports nothing. A command's own--dry-runwithout an exported variable still ends withis_dry_run()false andin_dry_run_invocation()true, astests/commands/test_entry_point.py:118-131asserts. The one run whose final state the entry call changes is an exportedDEVOPS_CLI_DRY_RUNwith a command's own--dry-run: the call sets_ACTIVATED_HERE(src/devops_cli/dry_run/state.py:26), sodry_run_requested_by_environment()returns False (src/devops_cli/dry_run/state.py:40) and the root callback clears the exported variable (src/devops_cli/main.py:302), contrary to the comment atsrc/devops_cli/main.py:295-300. [sources: src/devops_cli/main.py:268, src/devops_cli/main.py:273, src/devops_cli/main.py:158, src/devops_cli/core/cli.py:184, src/devops_cli/main.py:27, src/devops_cli/telemetry/tracer.py:1328, src/devops_cli/entry.py:50, src/devops_cli/dry_run/state.py:49, src/devops_cli/dry_run/state.py:26, src/devops_cli/dry_run/state.py:40, src/devops_cli/main.py:302, src/devops_cli/main.py:295, tests/commands/test_entry_point.py:131] - Should the call be deleted or kept with a new test?: Delete the call and the
set_dry_runimport.docs/TESTING.mdrecords that a line no public behaviour reaches is dead code and is deleted, not covered by a test that reaches past the public interface. No run that stops before the root callback reads the state, so the issue's second branch, a test through the public interface that fails without the call, has no case. The early-stop runs keep their output and exit code, and the invocation mark stays. (best practice) [sources: docs/TESTING.md:185, src/devops_cli/main.py:302, src/devops_cli/entry.py:52, src/devops_cli/dry_run/state.py:33]- Chosen: Delete the call and the import. No early run reads the state, the root callback sets the final state for every run that reaches a command, and docs/TESTING.md:185 says dead code is deleted.
- Rejected: Keep the call and add a test that fails without it. No run that stops before the root callback reads the state, so no public-interface test can fail without the call.
- Rejected: Keep the call with no test. No caller needs it, and the project's dead-code rule says such a line is deleted, not kept without a guard.
- Does an exported
DEVOPS_CLI_DRY_RUNwith a command's own--dry-runneed the entry call to keep the state?: No. The call sets_ACTIVATED_HERE, sodry_run_requested_by_environment()reports False and the root callback clears the exported variable, which contradicts the comment atsrc/devops_cli/main.py:295-302that an exported request must survive. Deleting the call leaves the exported request on, and a test of that run fails if the call returns. (best practice) [sources: src/devops_cli/main.py:295, src/devops_cli/dry_run/state.py:33, src/devops_cli/dry_run/state.py:23, src/devops_cli/entry.py:49]- Chosen: Delete the call and test the exported-env run. It keeps the exported request, as the root callback's comment records, and the test fails if the call returns.
- Rejected: Keep the call to clear the exported state. It discards a request the caller exported, contrary to src/devops_cli/main.py:295-302 and src/devops_cli/dry_run/state.py:33-40.
- Rejected: Delete the call without a test for the exported-env run. The one state change would be unguarded, and a later re-add of the call would pass the suite.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 7, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
refactorprefix of the title gives the type.(cli)scope of the title gives the scope.Dead code removal with no user-visible effect and no blocking dependency.Removes a redundant call; no user-facing behaviour changes.Delete one call and one import, or add one test through the public interface.Both concern dry-run state in entry.py, but #3901 migrates tests to the public interface while this item removes a dead code call found during that work.devops-cli-service commentedon Nov 9, 2026
Alternatives check: not-applicable
Class: refactor. The check makes no search and no model call for an item of this class.
Tool: none found
Checked on 2026-11-09. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 9, 2026
Status set to Ready at 1b37dbc (see proposed design in issue body).
refactor(cli): entry.main sets a dry-run state that is set again (#4286)
devops-cli-service commentedon Nov 10, 2026
Released in v0.103.1: https://github.com/dan-petty/devops-cli/releases/tag/v0.103.1
devops-cli-service commentedon Nov 10, 2026
Live since 2026-11-09 23:58 UTC