Skip to content

fix ModuleNotFoundError for click on fresh installs - #222

Open
cartertemm wants to merge 1 commit into
punitarani:mainfrom
cartertemm:fix-click-dependency
Open

fix ModuleNotFoundError for click on fresh installs#222
cartertemm wants to merge 1 commit into
punitarani:mainfrom
cartertemm:fix-click-dependency

Conversation

@cartertemm

@cartertemm cartertemm commented Jul 30, 2026

Copy link
Copy Markdown

Thanks for your work on this library, it has already saved me quite a bit of money!

pipx install flights and uv tool install flights are all broken on a fresh install right now. Any environment that resolves dependencies from scratch today gets typer 0.26 or newer, and the CLI dies on import:

ModuleNotFoundError: No module named 'click'

Cause

fli/cli/utils.py does from click import Context, Parameter, but click was never declared as a dependency. It worked by accident, because typer pulled in click.

As of typer 0.26.0, this is no longer the case. Typer now vendors click as typer._click. Its only declared dependencies are shellingham, rich, annotated-doc, and colorama.

Fix

Instead of adding click as a dependency, I switched to typer's public re-exports, typer.Context and typer.CallbackParam. Newer versions of typer use these, and they are backward compatible.

I also declared two packages in pyproject.toml that are imported directly but only installed because they are required by third-party modules, to prevent this from happening in another release:

  • rich>=13.8.0 in the main dependencies (imported in fli/cli/, currently imported by typer)
  • mcp>=1.2.0 in the mcp extra (imported in fli/mcp/, currently imported by fastmcp)

Verification

Reproduced the failure on main with a plain pip install . into a clean venv, then confirmed the following against the patched tree:

  • pip install . into a fresh venv, fli --help works
  • uv tool install ., fli --help works, all four subcommands listed
  • uv tool install ".[mcp]", import fli.mcp.server succeeds
  • Both typer callback validators still behave (a bad --currency and a bad date each produce the right error)
  • uv run ruff check . passes
  • tests/cli and tests/mcp: 236 passed

Not all the tests pass, but that looks to be mostly Google's fault, plus a windows encoding issue. The same number of tests pass here as on main.

Greptile Summary

Updates dependency declarations to keep fresh installations importable.

  • Replaces direct Click callback type imports with Typer’s public re-exports.
  • Declares Rich as a direct runtime dependency.
  • Declares MCP as a direct dependency of the optional MCP extra.
  • Synchronizes the generated uv lockfile metadata.

Confidence Score: 5/5

The PR appears safe to merge, with the import fix and dependency metadata aligned across the source and package configuration.

The changed callback annotations preserve Typer callback behavior while eliminating the undeclared Click import, and the newly explicit dependencies are reflected consistently in the project manifest and lockfile.

Important Files Changed

Filename Overview
fli/cli/utils.py Callback annotations now use Typer’s public Context and CallbackParam exports, removing the undeclared direct Click import.
pyproject.toml Rich and MCP are explicitly declared in the installation scopes where repository modules import them.
uv.lock Lockfile project metadata is synchronized with the new direct Rich and optional MCP dependency declarations.

Reviews (1): Last reviewed commit: "fix ModuleNotFoundError for click on fre..." | Re-trigger Greptile

Context used:

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