dev: accept argv, guard stdout.reconfigure, and reject whitespace --out #2278
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!2278
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/dev-cli-safety"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request successfully merged and closed
Claimed in the coordination issue as: DEV-CLI-STDOUT-RECONFIGURE-AND-ARGV-SAFETY (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7191757339)
What and why
scripts/dev.pypreviously:main()with noargvparameter, preventing programmatic or in-process testing.sys.stdout.reconfigure(encoding="utf-8")unguarded indiscover, raisingAttributeErrorwhensys.stdoutis replaced withio.StringIOor another non-reconfigurable stream.--out " "as a valid--out PATHinguest-scene.This adds
argv: list[str] | None = Nonetomain(), wrapssys.stdout.reconfigure(encoding="utf-8")intry/except (AttributeError, ValueError, OSError), rejects whitespace-only--outinguest_scene(), and adds unit tests intests/test_dev_discovery.py.Tested
python -I tests/test_dev_discovery.py -v(5 passed)python -I tests/test_dev_guest_scene.py -v(4 passed)upstream/mainbaseline negative control: failed withtests/test_dev_discovery.pybefore the fixpython -I tests/test_ci_registration.py,python -I tests/test_text_write_line_endings.py,python -I scripts/check_no_game_data.py,python -I -m compileall -q, andgit diff --cached --checkGPUs tested: n/a
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.Tested on Windows 11, Python 3.12.10, with this PR merged onto current upstream main.
tests/test_dev_discovery.py: 5 passed, 2 subtests passed (main: 4 passed).(AI-assisted test run; output checked by hand.)
Approving 0da952685.
A blank
--outis refused,maintakes argv for tests, andsys.stdout.reconfigurefailing (a replaced or detached stdout) no longer ends the run.Merged onto
maind1dff7949in one batch with 15 other tool PRs of this series (no conflicts), on Linux with Python 3.13.tests/test_dev_discovery.py: 5 passed (main: 4). AI-assisted (Claude Code, Claude Opus 5.5).Red/green: tests/test_dev_discovery.py errors on main (TypeError: main() takes 0 positional arguments) and passes with the PR merged, on GitHub Actions Linux and natively on Windows.
Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main 7daa4a4a5 in GitHub Actions: no new failure.
AI-assisted (Claude Code, Claude Opus 5.5)