Check whether uv is a dep or dev dep as part of its availability heuristic#1594
Check whether uv is a dep or dev dep as part of its availability heuristic#1594nathanjmcdougall merged 7 commits intomainfrom
Conversation
When the uv CLI subprocess check fails, fall back to checking whether uv is declared as a project dependency ([project.dependencies]) or in a dependency group ([dependency-groups]) in pyproject.toml. Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/f8de9a0d-3628-4e2d-96fb-b0e4aa7fb971 Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
src/usethis/_backend/uv/available.py
Outdated
|
|
||
| # Collect from project dependencies | ||
| try: | ||
| project_section = content["project"] |
There was a problem hiding this comment.
We already have mature, tested functions for extracting dependencies, please use those.
There was a problem hiding this comment.
Refactored in 3c92360. The _backend layer cannot import from _deps (import-linter enforces acyclic siblings), so the helpers _get_project_deps and _get_dep_group_deps mirror the patterns from get_project_deps()/get_dep_groups() using only permitted layers (_file, _types). They use Dependency, Requirement, and PyprojectTOMLManager — the same building blocks as the _deps functions. A docstring in _is_uv_a_dep() documents the architectural constraint.
There was a problem hiding this comment.
@copilot Nope, that's not the way to approach this. You can keep the _backend <- _deps flow but introduce a lower-level module and move the shared functions into that. Please use the shared helpers
There was a problem hiding this comment.
Addressed in 49b4035. Created _file/pyproject_toml/deps.py as a shared lower-level module with get_project_deps() and get_dep_groups(). _deps.py now wraps those with error translation (PyprojectTOMLDepsError → UVDepGroupError/DepGroupError). available.py imports from the shared module directly — no more duplicated logic.
Replace lazy import approach with architecture-compliant helpers that mirror get_project_deps()/get_dep_groups() using only _file and _types layers (permitted by import-linter). Uses TOMLDocument type, Dependency model, and packaging.requirements.Requirement for proper parsing. Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/99da146b-5070-472d-a959-ddb17f09c237 Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Extract get_project_deps() and get_dep_groups() into a shared lower-level module at _file/pyproject_toml/deps.py that both _backend and _deps can import from. _deps.py now wraps the shared functions with error translation. _backend/uv/available.py uses the shared helpers directly. Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/c1af1dd1-49e0-443d-866d-ffb972b62b89 Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Use (PyprojectTOMLError, InvalidRequirement) instead of bare Exception to avoid silently swallowing unexpected errors. Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/c1af1dd1-49e0-443d-866d-ffb972b62b89 Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
|
@copilot static checks are failing |
…ed module Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/ba30f96a-2900-47ab-80a4-211d87dffd9b Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
_file/pyproject_toml/deps.py_deps.pyto wrap shared helpers with error translation_backend/uv/available.pyto use shared helperspydantic,Requirement,TypeAdapter) from_deps.py📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.