Skip to content

Check whether uv is a dep or dev dep as part of its availability heuristic#1594

Merged
nathanjmcdougall merged 7 commits intomainfrom
copilot/check-uv-dependency-status
Mar 30, 2026
Merged

Check whether uv is a dep or dev dep as part of its availability heuristic#1594
nathanjmcdougall merged 7 commits intomainfrom
copilot/check-uv-dependency-status

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 27, 2026

  • Extract shared dep-reading logic to _file/pyproject_toml/deps.py
  • Update _deps.py to wrap shared helpers with error translation
  • Update _backend/uv/available.py to use shared helpers
  • Fix static checks: remove unused imports (pydantic, Requirement, TypeAdapter) from _deps.py
  • All tests pass

📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

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>
Copilot AI changed the title [WIP] Check whether uv is a dep or dev dep Check whether uv is a dep or dev dep as part of its availability heuristic Mar 27, 2026
Copilot AI requested a review from nathanjmcdougall March 27, 2026 10:20

# Collect from project dependencies
try:
project_section = content["project"]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have mature, tested functions for extracting dependencies, please use those.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

@nathanjmcdougall nathanjmcdougall Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 (PyprojectTOMLDepsErrorUVDepGroupError/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
Copy link
Copy Markdown

codecov bot commented Mar 27, 2026

Codecov Report

❌ Patch coverage is 94.52055% with 4 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/usethis/_backend/uv/available.py 76.47% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 27, 2026

Merging this PR will not alter performance

✅ 2 untouched benchmarks


Comparing copilot/check-uv-dependency-status (084f62d) with main (ebb0ef2)

Open in CodSpeed

Copilot AI and others added 2 commits March 28, 2026 09:18
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>
@nathanjmcdougall
Copy link
Copy Markdown
Collaborator

@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>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 28, 2026

@copilot static checks are failing

Fixed in 084f62d. The issue was unused imports (pydantic, Requirement, TypeAdapter) left in _deps.py after extracting the logic to the shared _file/pyproject_toml/deps.py module. All static checks pass now.

@nathanjmcdougall nathanjmcdougall merged commit b438c90 into main Mar 30, 2026
20 checks passed
@nathanjmcdougall nathanjmcdougall deleted the copilot/check-uv-dependency-status branch March 30, 2026 04:47
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.

Check whether uv is a dep or dev dep as part of its availability heuristic

2 participants