Skip to content

salli-server runs with Typer 0.29: the --json flag built from a declaration - #222

Merged
chandralegend merged 2 commits into
mainfrom
fix/typer-029-json-flag
Nov 10, 2026
Merged

chandralegend merged 2 commits into
mainfrom
fix/typer-029-json-flag

Conversation

@chandralegend

Copy link
Copy Markdown
Contributor

with_json_option (src/salli/interfaces/cli/support.py) constructed TyperOption(...) itself to add --json to every command. Typer 0.29 made type_descriptor a required argument of that constructor, so wherever 0.29 is installed every salli-server command fails at start-up:

TypeError: TyperOption.__init__() missing 1 required keyword-only argument: 'type_descriptor'

The lock pins 0.26.7, so this repository's CI, the image and the Render build were fine. A pip install of the wheel resolves typer[all]>=0.12 to 0.29, and so did salli-hosted's test job (leafmonkeylabs/salli#31). typer.main.get_click_param, the other candidate, does not survive either: 0.29 renamed it to the private _get_param.

The fix. _json_flag() declares the option with typer.Option on a throwaway command and takes the option Typer builds from it, as it builds every other option. Nothing depends on a constructor's arguments, only on typer.Typer, typer.Option and typer.main.get_command, which main.cli() already uses. Behaviour is unchanged: the flag is eager, not exposed, has the same help text, shows no default or env var, and its callback is _enable_json itself. No upper bound on Typer.

Tests. A new unit test checks each command's flag (opts, eager, not exposed, the callback, the help text) and that --help shows it.

Checked locally:

  • Every --help page (28: the root, the groups, every command) is byte-identical to main's under the lock's 0.26.7.
  • salli-server --help, db upgrade --json, db current --json and doctor --json against a scratch Postgres exit 0 with JSON on stdout and messages on stderr, under both 0.26.7 and 0.29.0. Main's code under 0.29.0 fails with the TypeError above.
  • tests/unit/cli, tests/integration/test_server_setup.py and test_usage_counts.py pass under Typer 0.26.7, 0.26.8, 0.27.0, 0.27.3, 0.28.0 and 0.29.0 (uv run --with typer==X).

🤖 Generated with Claude Code

chandralegend and others added 2 commits November 10, 2026 19:09
…a declaration

with_json_option called TyperOption(...) directly, and Typer 0.29 made
type_descriptor a required argument of it, so every command failed with a
TypeError wherever 0.29 was installed (a pip install of the wheel today;
salli-hosted's test job). The lock's 0.26.7 hid it.

_json_flag now declares the option with typer.Option on a throwaway command
and takes the option Typer builds, so it depends on no constructor's
arguments: still eager, not exposed, the same help text and _enable_json
itself as its callback. Every help page is byte-identical to main's under
0.26.7, and the CLI tests pass with Typer 0.26.7, 0.26.8, 0.27.0, 0.27.3,
0.28.0 and 0.29.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…in CI

Typer forces a terminal where GITHUB_ACTIONS (or FORCE_COLOR) is set, and the
highlighter splits "--json" with escape codes, so the assertion failed in CI
and passed locally. Strip the SGR codes before looking for it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chandralegend
chandralegend merged commit 5c5b3b2 into main Nov 10, 2026
17 checks passed
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