fix: resolve UsageError from the installed typer's Click - #272
Merged
Merged
Conversation
typer 0.25+ vendors its own copy of Click and no longer depends on the click package, so `import click` in cli.py broke every fresh install: `uv tool install bambox` produced a CLI that died with ModuleNotFoundError: No module named 'click'. Declaring click as a dependency would not be enough — typer raises its vendored typer._click UsageError, which is a different class from the standalone click.UsageError, so main()'s handler would silently stop matching and usage errors would traceback instead of exiting 2. Resolve UsageError from typer's vendored Click, falling back to the click package for typer < 0.25, and assert the hierarchy in a test so it cannot drift again. Also refreshes the stale version pin in uv.lock. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011aB9rCzbxyCrr7ZcXEN7g5
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011aB9rCzbxyCrr7ZcXEN7g5
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment Thanks for integrating Codecov - We've got you covered ☂️ |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
uv tool install bambox(andpip install bambox) produces a CLI that crashes immediately:cli.pyimportedclickbut never declared it — it arrived transitively via typer. typer 0.25+ vendors its own copy of Click (typer._click) and dropped theclickrequirement, so a fresh resolve gets typer 0.27.2 with noclickin the environment.uv.lockpins typer 0.24.1, which still depends on click, so local dev and CI never saw it.Fix
Resolve
UsageErrorfrom whichever Click the installed typer actually uses:Adding
clicktodependencieswould not have been sufficient: under typer 0.27 the standaloneclick.UsageErroris a different class from the one typer raises, somain()'s handler would silently stop matching and usage errors would traceback instead of exiting 2.Also refreshes the stale
bamboxversion pin inuv.lock(0.4.7 → 0.6.1).Verification
In a throwaway venv with typer 0.27.2 and no
clickinstalled:bambox --help— worksbambox pack t.gcode -o t.gcode.3mf— writes a valid archivebambox validate t.gcode.3mf— worksbambox --nonexistent-flag— prints✘ No such option: --nonexistent-flag, exits 2New test
TestUsageErrorHandlingassertstyper.BadParameteris a subclass of theUsageErrorcli.pyresolved, so the hierarchy cannot drift again on either typer generation.Pre-PR checklist: ruff check ✔, ruff format ✔, mypy ✔,
pytest -m "not e2e"398 passed. (Thetest_e2e_cura_vs_bbl.pyerrors on a full local run are pre-existing — they need the estampo CLI + Docker.)🤖 Generated with Claude Code
https://claude.ai/code/session_011aB9rCzbxyCrr7ZcXEN7g5