Skip to content

fix: add click to base install dependencies#610

Merged
dionhaefner merged 2 commits into
mainfrom
jpb/fix-click-dep
May 27, 2026
Merged

fix: add click to base install dependencies#610
dionhaefner merged 2 commits into
mainfrom
jpb/fix-click-dep

Conversation

@jpbrodrick89

@jpbrodrick89 jpbrodrick89 commented May 27, 2026

Copy link
Copy Markdown
Contributor

Summary

The Test pip install (ubuntu-latest, 3.14, latest) CI job has been failing on main (e.g. https://github.com/pasteurlabs/tesseract-core/actions/runs/26502477818/job/78046217060). Two related issues, both exposed by newer typer / a base-only install:

1. ModuleNotFoundError: No module named 'click'

tesseract_core/sdk/cli.py does import click unconditionally and the SDK CLI is exposed via [project.scripts], so click must be in the base install — not only in the runtime extra. Until now it was pulled in as a transitive dependency of typer, but newer typer releases (>= 0.16 ish) no longer guarantee this, so pip install tesseract-core with the latest dep set fails at CLI import.

2. RuntimeError: Type not yet supported: <class 'click.core.Context'> (then typeguard hit too)

Once click is installed, a second latent issue surfaces in cli.py:run_container. It declared its context parameter as click.Context, which fails at typer command registration on typer >= 0.16. Annotating as typer.Context (a thin subclass of click.Context) gets past typer's resolver but then trips typeguard at call time, because the context object click actually injects at runtime is a plain click.Context, not an instance of the typer.Context subclass:

typeguard.TypeCheckError: argument "context" (click.core.Context)
    is not an instance of typer.models.Context

The context was only used to invoke context.get_help() in two branches. Drop the parameter entirely and look the context up via click.get_current_context() at the point of use, which avoids both the typer parameter-type check and the typeguard runtime check.

Commits

  1. fix: add click to base install dependencies— declareclickas a real dependency. Pre-commit hooks regenerateproduction.uv.lock/requirements.txt; lockfile churn is mostly cosmetic (the pinned uv 0.6.11` in the hook re-serialises every entry).
  2. fix: drop click.Context parameter from run_container — remove the offending parameter from run_container's signature; replace context.get_help() with click.get_current_context().get_help() at the two call sites.

Test plan

  • Test pip install (latest) — should clear the ModuleNotFoundError.
  • tesseract --help / tesseract run --help still work locally.
  • tesseract run (no args) still surfaces the same BadParameter errors via typer's existing error rendering.

🤖 Generated with Claude Code

`tesseract_core/sdk/cli.py` imports `click` unconditionally (alongside
`typer`) and the SDK CLI is exposed via `[project.scripts]`, so `click`
must be installed as part of the base package. Previously it was only
listed under the `runtime` extra, which worked in practice because
older `typer` versions pulled `click` in as a hard transitive
dependency. Newer `typer` releases no longer guarantee this, causing
`Test pip install (latest)` jobs to fail with
`ModuleNotFoundError: No module named 'click'`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented May 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.08%. Comparing base (7cdeb0b) to head (07bffda).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #610      +/-   ##
==========================================
- Coverage   77.13%   77.08%   -0.05%     
==========================================
  Files          32       32              
  Lines        4495     4495              
  Branches      739      739              
==========================================
- Hits         3467     3465       -2     
- Misses        726      728       +2     
  Partials      302      302              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

`cli.py:run_container` previously declared its context parameter as
`click.Context`, which failed at typer command registration on
`typer >= 0.16`:

    RuntimeError: Type not yet supported: <class 'click.core.Context'>

Annotating as `typer.Context` (a thin subclass of `click.Context`) gets
past typer's resolver but trips typeguard at call time, because the
context object click actually injects at runtime is a plain
`click.Context`, not an instance of the `typer.Context` subclass:

    typeguard.TypeCheckError: argument "context" (click.core.Context)
        is not an instance of typer.models.Context

The context was only used to invoke `context.get_help()` in two
branches. Drop the parameter entirely and look the context up via
`click.get_current_context()` at the point of use, which avoids both
the typer parameter-type check and the typeguard runtime check.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@PasteurBot

Copy link
Copy Markdown
Contributor

Benchmark Results

Benchmarks use a no-op Tesseract to measure pure framework overhead.

🚀 3 faster, ⚠️ 0 slower, ✅ 33 unchanged

Notable changes

Benchmark Baseline Current Change Status
decoding/base64_1,000 0.029ms 0.025ms -12.4% 🚀 faster
decoding/base64_100,000 0.791ms 0.649ms -17.9% 🚀 faster
roundtrip/base64_100,000 0.899ms 0.764ms -15.0% 🚀 faster
Full results
Benchmark Baseline Current Change Status
api/apply_1,000 0.504ms 0.500ms -0.9%
api/apply_100,000 0.506ms 0.494ms -2.5%
api/apply_10,000,000 0.506ms 0.494ms -2.4%
cli/apply_1,000 1686.465ms 1728.849ms +2.5%
cli/apply_100,000 1689.622ms 1716.956ms +1.6%
cli/apply_10,000,000 1731.901ms 1794.013ms +3.6%
decoding/base64_1,000 0.029ms 0.025ms -12.4% 🚀 faster
decoding/base64_100,000 0.791ms 0.649ms -17.9% 🚀 faster
decoding/base64_10,000,000 71.912ms 72.218ms +0.4%
decoding/binref_1,000 0.186ms 0.187ms +0.2%
decoding/binref_100,000 0.240ms 0.238ms -0.5%
decoding/binref_10,000,000 9.293ms 9.302ms +0.1%
decoding/json_1,000 0.099ms 0.098ms -0.6%
decoding/json_100,000 9.327ms 9.357ms +0.3%
decoding/json_10,000,000 1115.759ms 1116.979ms +0.1%
encoding/base64_1,000 0.028ms 0.027ms -3.2%
encoding/base64_100,000 0.144ms 0.144ms +0.0%
encoding/base64_10,000,000 22.654ms 23.177ms +2.3%
encoding/binref_1,000 0.279ms 0.276ms -1.1%
encoding/binref_100,000 0.449ms 0.449ms -0.1%
encoding/binref_10,000,000 17.114ms 17.273ms +0.9%
encoding/json_1,000 0.143ms 0.142ms -0.8%
encoding/json_100,000 14.404ms 14.345ms -0.4%
encoding/json_10,000,000 1517.015ms 1515.092ms -0.1%
http/apply_1,000 3.002ms 2.923ms -2.6%
http/apply_100,000 8.261ms 8.403ms +1.7%
http/apply_10,000,000 682.810ms 667.496ms -2.2%
roundtrip/base64_1,000 0.057ms 0.058ms +1.6%
roundtrip/base64_100,000 0.899ms 0.764ms -15.0% 🚀 faster
roundtrip/base64_10,000,000 95.718ms 95.472ms -0.3%
roundtrip/binref_1,000 0.478ms 0.474ms -0.8%
roundtrip/binref_100,000 0.692ms 0.696ms +0.6%
roundtrip/binref_10,000,000 26.843ms 26.669ms -0.6%
roundtrip/json_1,000 0.246ms 0.245ms -0.5%
roundtrip/json_100,000 21.432ms 21.565ms +0.6%
roundtrip/json_10,000,000 2624.146ms 2626.160ms +0.1%
  • Runner: Linux 6.17.0-1015-azure x86_64

@dionhaefner dionhaefner left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm, thanks

@dionhaefner
dionhaefner enabled auto-merge (squash) May 27, 2026 12:00
@dionhaefner
dionhaefner merged commit 72523bd into main May 27, 2026
92 of 94 checks passed
@dionhaefner
dionhaefner deleted the jpb/fix-click-dep branch May 27, 2026 12:05
@pasteurlabs pasteurlabs locked and limited conversation to collaborators May 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants