Skip to content

fix(cli): give actionable error when 'deep' runs without cli extra (#594)#608

Open
uttam12331 wants to merge 1 commit into
qlustered:masterfrom
uttam12331:fix/cli-missing-click-594
Open

fix(cli): give actionable error when 'deep' runs without cli extra (#594)#608
uttam12331 wants to merge 1 commit into
qlustered:masterfrom
uttam12331:fix/cli-missing-click-594

Conversation

@uttam12331

Copy link
Copy Markdown

Summary

Fixes #594.

The deep console script is declared in [project.scripts] and is therefore always installed, but its runtime dependencies (click, and pyyaml for YAML files) live in the optional cli extra. On a default install, running deep immediately imported deepdiff.commands, which does import click at module load, so the command died with a raw traceback:

$ uv tool install deepdiff
$ deep --help
Traceback (most recent call last):
  ...
  File ".../deepdiff/commands.py", line 1, in <module>
    import click
ModuleNotFoundError: No module named 'click'

Change

Point the entry point at a thin wrapper (deepdiff/cli.py:main) that checks for click first and, if it's missing, exits with an actionable message instead of a traceback:

$ deep --help
The 'deep' command line tool requires extra dependencies that are not installed.
Install them with:

    pip install deepdiff[cli]

When click is present, the wrapper simply defers to the existing deepdiff.commands.cli group, so behavior is unchanged for anyone who installed deepdiff[cli]. This keeps the CLI dependencies optional (as intended by the cli extra) rather than promoting click/pyyaml to core dependencies.

Tests

Added TestCliEntryPoint in tests/test_command.py:

  • test_main_runs_cli_when_click_available — the wrapper runs the CLI group normally when click is installed.
  • test_main_reports_missing_click_dependency — with click import forced to fail, main() exits with the pip install deepdiff[cli] hint (reproduces cli - Missing dependency 'click' in default installation #594).

Full tests/test_command.py suite passes (25 passed). Also verified end-to-end in a fresh venv without the cli extra: deep now prints the hint and exits 1 instead of raising ModuleNotFoundError.

The `deep` console script is always installed, but its dependencies
(`click`, and `pyyaml` for YAML files) live in the optional `cli` extra.
On a default install, running `deep` imported `deepdiff.commands`, which
imports `click` at module load, so the command died with a bare
`ModuleNotFoundError: No module named 'click'`.

Point the entry point at a thin wrapper that checks for `click` first and
exits with an actionable message (`pip install deepdiff[cli]`) instead of a
traceback, keeping the CLI dependencies optional as intended.

Fixes qlustered#594
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.

cli - Missing dependency 'click' in default installation

1 participant