Skip to content

build: lift the Typer, Click and Rich version holds - #535

Merged
jsenecal merged 1 commit into
mainfrom
build/531-cli-deps
Nov 21, 2026
Merged

jsenecal merged 1 commit into
mainfrom
build/531-cli-deps

Conversation

@jsenecal

Copy link
Copy Markdown
Collaborator

Problem

pyproject.toml held the CLI dependencies at old versions: typer>=0.9.0,<0.10.0 (locked 0.9.4), click==8.1.7 and rich<=14.0.0 (locked 13.9.4). #394 added the holds because Typer 0.9 breaks with Click 8.2+. Now that Renovate manages Python (#528), it proposes updates that the holds block.

Change

  • pyproject.toml: typer>=0.29.2, rich>=13.9.4, no upper bounds. The direct click dependency is removed. Typer 0.26.0 vendors Click and no longer depends on it (release notes), and after the change below no hyperglass code imports click. Click stays in the lock through uvicorn, litestar (rich-click) and black.
  • uv.lock: uv lock --upgrade-package typer --upgrade-package click --upgrade-package rich. Changed packages only:
    • typer 0.9.4 → 0.29.2
    • click 8.1.7 → 8.5.1
    • rich 13.9.4 → 15.0.0
    • annotated-doc 0.0.7 and shellingham 1.5.4 added (new Typer dependencies). Typer now also requires pydantic, which was already locked, and no longer requires typing-extensions, which other packages still pull in.
  • hyperglass/cli/onboard/prompts.py: the onboard device port prompt passed click.IntRange(1, 65535) to typer.prompt. Typer 0.29 validates prompt input with Pydantic (0.29.0 notes) and no longer accepts Click types (Vendored Click): with the old code, every answer to the port prompt raised AssertionError. The prompt now uses Annotated[int, Field(ge=1, le=65535)]. It asks again when the input is out of range or not an integer, as before.
  • hyperglass/cli/main.py:
    • run() called typer.run(cli()). cli() parses sys.argv and exits by itself, so the outer typer.run never ran. It now calls cli().
    • Two functions were named _version: the --version callback, and the app callback that replaced it. The callback is now _print_version, the app callback is _main, and --version is is_eager so it runs before other parameters.
    • plugins --input/--output: removed is_flag=True. Typer deprecated it (0.13.0) and 0.29.2 warns about it. bool options are already flags.
    • rich._inspect.Inspect stays, with a comment. It still exists in Rich 15 with the same signature. The public rich.inspect() prints and returns None, and devices/directives need the renderable to lay panels out in Columns. The new tests run these commands, so a Rich change that removes it fails CI.
  • Tests: CliRunner(mix_stderr=False) → CliRunner(). Click 8.2.0 removed mix_stderr and always keeps stderr separate (Click CHANGES, 8.2.0).

Tests

New in hyperglass/cli/tests/ (27 tests):

  • test_command_help: --help for each of the 11 commands, the onboard group and its 4 subcommands (16 cases).
  • test_commands_cover_cli: that list equals the registered commands and subcommands, so a new command without a help test fails.
  • test_version, test_no_arguments_shows_help.
  • test_inspect_commands: devices, devices test1, directives, directives juniper_bgp_route, params, params messages.no_input, plugins against the test state (fakeredis), checking the output and that the device password does not appear.
  • test_port_prompt_rejects_out_of_range_values: 0, 65536, ssh are rejected, then 2222 is accepted.
$ uv sync --locked --extra ui --python 3.12
$ uv run pytest hyperglass --ignore hyperglass/plugins/external -q
4173 passed, 4 skipped
$ uv run ruff check .
All checks passed!

hyperglass/cli and the support-bundle tests also pass on Python 3.11 (83 passed). main has 4146 tests; the 27 above are the difference.

Entrypoint from the venv: hyperglass --version prints 3.0.0rc2, and hyperglass <command> --help exits 0 for all 16 commands and subcommands.

Image:

$ docker build -t hg531 .            # succeeds
$ docker run --rm hg531 hyperglass --help        # exit 0
$ docker run --rm hg531 sh -c 'hyperglass --version; id -u'
3.0.0rc2
10001
# typer 0.29.2, click 8.5.1, rich 15.0.0 in /opt/venv

Changelog

  • Update the CLI dependencies: Typer 0.29, Rich 15, and Click 8.5 through other packages. hyperglass with no arguments now exits with status 2 after printing the help.

Notes

Visible CLI changes, all from upstream releases:

  • hyperglass with no arguments prints the help and exits with status 2 instead of 0. Click 8.2.0: "If help is shown because no_args_is_help is enabled …, the exit code is 2 instead of 0."
  • --help lists commands in definition order instead of alphabetically (Typer 0.13.0, "Show help items in order of definition"), and shows a type column such as <bool> (Typer 0.27.0, "Update metavar printing").
  • Rich tracebacks from an unhandled CLI error no longer show local variables by default (Typer 0.23.0). Locals can hold credentials, so the new default is safer.
  • Rich 14.0.0 treats an empty NO_COLOR or FORCE_COLOR as unset. Nothing in this repository sets them.

Not changed here: .tests/ga-backend-app.sh runs hyperglass.console setup -d. setup has no -d option with either Typer version, and the script ignores the failure. That is unrelated to this change and stays as it is.

Closes #531

Raise typer to >=0.29.2 and rich to >=13.9.4 with no upper bound, and
drop the direct click==8.1.7 pin. Typer vendors Click since 0.26.0, so
nothing in hyperglass imports click any more; uvicorn, litestar and
black still pull it in.

- onboard: the port prompt passed click.IntRange to typer.prompt, which
  Typer 0.29 no longer accepts (AssertionError on input). Use an
  Annotated int with Pydantic bounds, which Typer validates.
- run() called typer.run(cli()); call cli() directly.
- Rename the duplicate _version callback and make --version eager.
- Drop is_flag from the plugins options; Typer deprecates it.
- Tests: CliRunner no longer takes mix_stderr (Click 8.2). Add --help
  tests for every command and subcommand, a check that the list covers
  every registered command, --version, the no-argument usage, the
  Inspect-based commands against test state, and the port prompt range.

rich._inspect.Inspect stays: rich.inspect() only prints, and the
devices/directives commands need the renderable for Columns.

Closes #531
@jsenecal jsenecal added backend Python backend: API, models, state, execution dependencies Pull requests that update a dependency file labels Nov 21, 2026
@jsenecal jsenecal self-assigned this Nov 21, 2026
@jsenecal
jsenecal requested a review from WilhelmZA November 21, 2026 02:13
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 85.377% (+0.3%) from 85.11% — build/531-cli-deps into main

@WilhelmZA WilhelmZA left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving at 0c125ddd.

I read the dependency changes, the lock file and the CLI changes. Nothing in hyperglass/ imports click directly any more, the hyperglass.console:run entry point still resolves, and the new lock entries (annotated-doc, shellingham) have permissive licences. CI gate passes and every commit is verified.

#526 also regenerates uv.lock, so the second one to merge needs a re-lock.

Nits:

  • The body has a Changelog entry but CHANGELOG.md is not edited. The no-argument exit status changes from 0 to 2, which scripts can depend on, so please add the entry under [Unreleased], here or in the release PR.
  • hyperglass/cli/tests/test_help.py: test_no_arguments_shows_help does not assert the exit code. assert result.exit_code == 2 would pin the documented behaviour.
  • hyperglass/cli/tests/test_help.py: the plugins case in test_inspect_commands expects "", which every string contains, so only the exit code is checked for that case.

@WilhelmZA WilhelmZA added the reviewing Issue is being reviewed by maintainers label Nov 21, 2026
@jsenecal
jsenecal merged commit b9db09f into main Nov 21, 2026
16 checks passed
jsenecal added a commit that referenced this pull request Nov 21, 2026
Typer 0.29 ships its own CliRunner, which takes only charset and env, so CliRunner(mix_stderr=False) in test_healthcheck.py raised TypeError at collection once #535 lifted the Typer hold, and main's CI broke. The healthcheck command prints only to stdout and the tests check exit codes, so a plain CliRunner() is enough. That collection error also hid test_help.py::test_commands_cover_cli, which fails because COMMANDS lacked healthcheck (#524); it is added.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Python backend: API, models, state, execution dependencies Pull requests that update a dependency file reviewing Issue is being reviewed by maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lift the Typer, Click and Rich version holds

3 participants