Add helpful hint error message if optional dependencies not yet installed. - #1656
Add helpful hint error message if optional dependencies not yet installed.#1656Sevans711 wants to merge 19 commits into
Conversation
also add string matching to test_check_requires_viz_and_geo in both the installed_with_geo and the installed_with_viz cases, and left a comment about why it wasn't added in the installed_with_no_opts case.
03869b5 to
8e2a07a
Compare
(maybe not necessary… but also trying to re-trigger CI jobs here, due to github actions downtime yesterday causing stalled jobs with no "rerun jobs" button available.)
also add string matching to test_check_requires_viz_and_geo in both the installed_with_geo and the installed_with_viz cases, and left a comment about why it wasn't added in the installed_with_no_opts case.
8e2a07a to
1210ae0
Compare
rajeeja
left a comment
There was a problem hiding this comment.
One unreachable branch, see inline.
| extra in need_extras for extra in extras | ||
| ): # still maybe in case (1) or (2). | ||
| pass # this package is already covered by other needed extras! | ||
| elif len(extras) == 0: # case (3) |
There was a problem hiding this comment.
Unreachable — the assert above guarantees len(extras) >= 2, so this likely wants >= 2 not == 0. Means a cartopy-only miss suggests [all] instead of [geo] or [viz].
There was a problem hiding this comment.
Thank you for looking into this! Commit 0f638de fixes this, makes slight improvements to message readability in case of many extras, and adds a test to the CI with expectations about the error messages. That test would have crashed before this fix, and it hard-codes the expected error messages for clarity and readability.
…/github.com/UXARRAY/uxarray into sevans/_raise_hint_if_optional_deps_missing
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
…_if_optional_deps_missing
| _raise_hint_if_optional_deps_missing("pyproj") | ||
| from pyproj import Geod |
There was a problem hiding this comment.
This pattern looks like it will be difficult to maintain consistently throughout the codebase as we develop it. If we're going to have this, there should definitely be some kind of linting for this so we'll know in the PRs if these are done correctly, and provide an easy way to fix it.
Addresses part of #1224 #1225 but does not fully close them.
Overview
Adds
_raise_hint_if_optional_deps_missingwhich raises helpful hint upon trying but failing to import optional dependencies due to them not yet being installed.PR Checklist
General
Testing & Benchmarking
Documentation
docs/api.rst_)AI Disclosure
AI Usage: GitHub Copilot inline code suggestions, some discussion with Claude.