fix(cli): give actionable error when 'deep' runs without cli extra (#594)#608
Open
uttam12331 wants to merge 1 commit into
Open
fix(cli): give actionable error when 'deep' runs without cli extra (#594)#608uttam12331 wants to merge 1 commit into
uttam12331 wants to merge 1 commit into
Conversation
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
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
Fixes #594.
The
deepconsole script is declared in[project.scripts]and is therefore always installed, but its runtime dependencies (click, andpyyamlfor YAML files) live in the optionalcliextra. On a default install, runningdeepimmediately importeddeepdiff.commands, which doesimport clickat module load, so the command died with a raw traceback:Change
Point the entry point at a thin wrapper (
deepdiff/cli.py:main) that checks forclickfirst and, if it's missing, exits with an actionable message instead of a traceback:When
clickis present, the wrapper simply defers to the existingdeepdiff.commands.cligroup, so behavior is unchanged for anyone who installeddeepdiff[cli]. This keeps the CLI dependencies optional (as intended by thecliextra) rather than promotingclick/pyyamlto core dependencies.Tests
Added
TestCliEntryPointintests/test_command.py:test_main_runs_cli_when_click_available— the wrapper runs the CLI group normally whenclickis installed.test_main_reports_missing_click_dependency— withclickimport forced to fail,main()exits with thepip install deepdiff[cli]hint (reproduces cli - Missing dependency 'click' in default installation #594).Full
tests/test_command.pysuite passes (25 passed). Also verified end-to-end in a fresh venv without thecliextra:deepnow prints the hint and exits1instead of raisingModuleNotFoundError.