Skip to content

Give hub city-still --width/--height a one-line range error - #257

Merged
dmccoystephenson merged 1 commit into
mainfrom
fix/city-still-size-usage-error
Nov 14, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
fix/city-still-size-usage-error

Conversation

@dmccoystephenson

@dmccoystephenson dmccoystephenson commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Summary

  • gardener hub city-still --width/--height were declared with choices=range(320, 4097) / choices=range(180, 4097). argparse's invalid-choice error lists every choice, so --width 5000 printed roughly 22 KB of comma-separated numbers (measured with the same add_argument call under argparse: 22,071 bytes) instead of naming the range. Both flags now use range-checked type= callables, city_width and city_height in gardener/cli.py, which follow the existing port_arg/city_hours pattern and raise a one-line ArgumentTypeError such as must be a whole number of pixels from 320 to 4096, got: '5000'. The accepted ranges and defaults are unchanged.
  • Both flags previously had no help text in --help, and each now has one that states its range and default.
  • docs/HUB.md's command table row for hub city-still now lists --weather-sample, which docs/USAGE.md and HUB.md's own "Weather" section already document.
  • docs/TESTING.md's test_cli.py paragraph names the new argparse types alongside the others.

The problem was not tracked in an issue; it was found during the cycle's triage scan for unhelpful error messages. No open issue was picked up because all four (#248, #154, #100, #94) are waiting on a maintainer decision.

Test plan

  • python3 -m compileall gardener
  • New TestCityStillSize in tests/test_cli.py: in-range values accepted at both ends, out-of-range and non-integer values rejected, parse-time exit 2 with an error under 1,000 characters that names 4096, and defaults (1280×720) kept.
  • Verify by removal: with gardener/cli.py restored from origin/main (and a check that def city_width occurs 0 times), the new class failed. With the fix restored, all 4 tests passed and git diff was empty.
  • CI (tests/ and the integration/ offline tier on Python 3.10 and the latest 3.x) is the anchor of record for this PR. The local run was only partial: the sandbox's python3 is 3.8, below requires-python, so tests.test_cli was run through an in-memory import shim kept outside the repo. That run had 339 tests, and the 13 errors in it come from the shim's own rewriting of module constants. None of them are in the new class.
  • No dispatch.py, dev_loop.py, or prompt template is touched, so no manual dispatch verification is required, and the "Safety model impact" checklist does not apply.

This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review: no blocking findings.

The code-review skill (low) was run on the diff and reported no correctness issues. A hand pass against this repo's conventions followed:

  • gardener/cli.py _city_pixels — the bounds are inclusive on both ends (320/180 to 4096), which matches the replaced choices=range(320, 4097) / range(180, 4097) exactly. A non-integer value maps to 0 and is rejected, which is safe because neither minimum is 0. The defaults 1280/720 lie inside the range.
  • gardener/cli.py hub_city --width/--height — the newly added help strings take their upper bound from CITY_MAX_PIXELS, so the help and the check cannot drift apart. The docs/USAGE.md flag-coupling test still holds, because both flags were already listed in the command reference.
  • docs/HUB.md:200 — the review asked whether --weather-sample exists. It is declared on hub city-still in gardener/cli.py and is already documented in USAGE.md and in HUB.md's "Weather" section, so the table row is now catching up with them.
  • Safety invariants: dispatch.py, MODE_SPECS, tend_mode_spec(), dev_loop.py, and the prompt templates are all untouched. bypassPermissions reachability and the gh pr merge gate are therefore unaffected, and no manual dispatch verification is owed.
  • No new test drives main(), cmd_tend or cmd_overnight, so the notifier, usage, and hub fences are not involved.
  • Verify by removal: the new class failed with gardener/cli.py restored from origin/main, after an assertion that def city_width occurred 0 times, and it passed once the fix was restored. That red came from an import error, so it is blunt. The behavioural assertion (error under 1,000 characters) was confirmed separately by measuring the old choices=range error at about 22 KB.
  • CI is the anchor of record, and it is green on the PR head: test (3.10), test (3.x), city-still, fleetcity, garden3d.

This review comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit 1195cf4 into main Nov 14, 2026
5 checks passed
@dmccoystephenson
dmccoystephenson deleted the fix/city-still-size-usage-error branch November 14, 2026 02:13
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