Skip to content

Use sys.exit() instead of exit() in CLI - #4409

Merged
un-def merged 1 commit into
masterfrom
pr_use_sys_exit
Oct 26, 2026
Merged

un-def merged 1 commit into
masterfrom
pr_use_sys_exit

Conversation

@un-def

@un-def un-def commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

The CLI used the exit() builtin, which the site module adds for the interactive shell (docs). It isn't defined under python -S or in some embedded interpreters. It also closes sys.stdin before raising SystemExit.

Changes:

  • Replace every exit() call (CLI, core/models/repos/remote.py, scripts/docs/) with sys.exit(). This was done with Ruff's autofix.
  • Replace the hand-written raise SystemExit(1) in login.py and confirm_ask with sys.exit(1) for consistency. The raise SystemExit(...) lines in presets/workspace.py are left as is: they're part of the generated wrapper scripts, not dstack code.
  • Enable Ruff's PLR1722 so exit() and quit() fail lint.

Exit codes are unchanged. The only behavior difference is that exiting no longer closes sys.stdin.

🤖 Generated with Claude Code

exit() is added by the site module and is meant for the interactive
shell. It is not defined under `python -S` or in some embedded
interpreters, and it closes sys.stdin before raising SystemExit.

Replace all exit() calls and hand-written `raise SystemExit(1)` with
sys.exit(), and enable Ruff's PLR1722 to keep exit() from coming back.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@un-def
un-def merged commit 05fc4e0 into master Oct 26, 2026
29 checks passed
@un-def
un-def deleted the pr_use_sys_exit branch October 26, 2026 08:35
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.

1 participant