Repository navigation
fix(cli): refuse --importance outside 1-10 on create and update as a usage error - #1428
swastiktawate wants to merge 1 commit into
Conversation
markramm
left a comment
There was a problem hiding this comment.
Automated review. I'm an AI agent that triages pull requests for this project's maintainer. A person reads these and makes the final call. If I've got something wrong, say so here.
Thank you for this fix. It is small and well aimed, and the PR body explains clearly what you checked.
Matches the issue: The change adds min=1, max=10 to --importance on create (entry_commands.py:312) and update (:542), the two-line change the groom on #1393 describes. Out-of-range values now exit 2 as a usage error, and 1 and 10 are still accepted.
Overlaps another open pull request: #1381, #1374, #1367 and #1311 also edit pyrite/cli/entry_commands.py. Their hunks are in other places (_report_link, delete_entry, imports, and the bodies of add_entry and update_entry), and none touches the --importance lines. Whichever lands second will need a rebase, but I see no shared lines.
Property coverage: The groom says "Whether the MCP create refuses 999 is not checked: out of scope here; note what you find in the PR." The PR body does not mention MCP. Other importance options in the checkout are read-side filters: browse_commands.py:450 (changed by #1427), read_cli.py:226 (changed by #1416), and link_commands.py:647, which has no bounds and which no open PR touches.
Tests: The tests go through the CLI entry point (world.cli). By my reading the out-of-range cases would exit 0 on dev, so they fail without the change. The text checks match the plain Error: ... line, so tests.cli_help.plain() is not needed. Two gaps against the groom: the acceptance names "error_code": "USAGE_ERROR" but no test asserts it (the create tests already pass --format json); and the regime "update without --importance (unchanged, None)" has no test. runner = CliRunner() in the test file is defined but unused.
Housekeeping: The changelog fragment follows the naming pattern and uses the right section. The commit prefix is fix(cli):. All checks passed on this head.
Needed before merge
- Assert
error_code == "USAGE_ERROR"in the parsed JSON for the create refusals. - Add an
updatetest that omits--importanceand checks the stored importance is unchanged.
Recommendation: merge after items 1 to 2.
The maintainer makes the final call.
This touches a CLI flag (--importance on create and update), so the merge is the maintainer's.
Generated by Claude Code
|
A note from the maintainer's loop: #1544 merged a test,
Declare the range with 🤖 Generated with Claude Code |
|
Automated note from the maintainer's conductor agent. Thank you for your patience; this PR is still wanted. Since it was opened, #1570 made the service refuse an importance outside 1 to 10 on every entry type, but the CLI options themselves still declare no range: on To land it:
A new head gets a fresh review within the hour. |
pyrite createandpyrite updateaccepted any integer for --importance even though the help says 1-10. An importance of 999 or -5 was written to the entry without complaint. This adds min=1, max=10 to the --importance option on both commands so Typer refuses out-of-range values with a clean usage error (exit 2), the way other bounded options already do. Values 1 and 10 stay valid.Fixes #1393
Test plan: 10 new tests in tests/test_cli_importance_range.py using the cli_world fixture: create --importance 999, 0, and -5 exit 2 naming --importance with no file written; create --importance 1 and 10 exit 0; update --importance 11, 0, and -1 exit 2 with the entry file byte-for-byte unchanged; update --importance 1 and 10 exit 0. Verified by hand that --importance 999 now prints
Error: Invalid value for '--importance' / '-i': 999 is not in the range 1<=x<=10.with error code USAGE_ERROR. Ran the neighboring suites: 405 tests in test_cli_commands, test_changelog_fragments, test_cli_usage_error_plain, and test_cli_errors, all passing. Ruff check and format clean.