test: import Result from typer.testing instead of click#206
Merged
Conversation
Newer typer releases no longer depend on click, so the transitive click install is no longer guaranteed and `from click.testing import Result` fails in CI. typer.testing re-exposes Result (backed by click.testing.Result on older typer, and typer._click.testing.Result on newer typer), so the import works across all supported typer versions without needing a direct click dependency.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #206 +/- ##
=======================================
Coverage 97.62% 97.62%
=======================================
Files 21 21
Lines 3238 3238
=======================================
Hits 3161 3161
Misses 77 77 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Summary
tests/test_cli.pyimportedResultfromclick.testingpurely as a return-type annotation for the localinvoke()helper. The project never declaredclickas a direct dependency — it was only present transitively becausetyper(pulled in via thecliextra) used to depend on it. Recent typer releases dropped theclickdependency, so fresh CI installs no longer getclick, and the import fails at test collection time, breaking the pipeline.Switching to
from typer.testing import Resultfixes this without adding a new dependency.typer.testingre-exposesResultacross the entiretyper>=0.12.0range declared inpyproject.toml:click.testing.Result(when click was still a transitive dep)typer._click.testing.Result(typer now vendors click internally)Verified empirically in both environments.
Test plan
test.yaml) passes on this branchtests/test_cli.pyimports resolve withoutclickinstalledGenerated by Claude Code