Don't infer uv is used if there's no lockfile but pyproject.toml a…#1163
Conversation
…ckfile-but-pyprojecttoml-already-exists
Pass tests, various version bumps
There was a problem hiding this comment.
Pull request overview
This PR fixes backend inference logic to prevent incorrectly inferring uv as the backend when pyproject.toml already exists but no lockfile is present. The changes ensure tests explicitly set backend=uv where needed, update version numbers for dependencies, and improve the backend detection algorithm.
Key changes:
- Modified backend inference to only auto-select
uvwhenpyproject.tomldoesn't exist yet - Updated tests to explicitly set
backend=BackendEnum.uvin contexts whereuvshould be used - Refactored conditional logic in tool implementations to use
elif/assert_neverpattern for exhaustiveness checking
Reviewed changes
Copilot reviewed 22 out of 24 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/usethis/_integrations/backend/dispatch.py | Refined backend inference logic to check for pyproject.toml existence before auto-selecting uv |
| src/usethis/_config.py | Added inferred_backend field to cache backend inference results |
| src/usethis/_ui/interface/doc.py | Added backend parameter to doc command |
| tests/conftest.py | Added [tool.uv] section to fixture to properly indicate uv usage |
| tests/usethis/_integrations/backend/test_dispatch.py | Added test case for pyproject.toml already existing scenario |
| tests/usethis/_ui/interface/test_tool.py | Updated test to explicitly pass --backend=uv flag |
| tests/usethis/_ui/interface/test_ci.py | Added [tool.uv] section to test fixture |
| tests/usethis/test_deps.py | Explicitly set backend=uv in test context |
| tests/usethis/_tool/impl/test_pytest.py | Set backend=uv in multiple test contexts and skipped one test |
| tests/usethis/_tool/impl/test_pre_commit.py | Added test isolation with change_cwd and files_manager |
| tests/usethis/_core/test_core_tool.py | Set backend=uv in multiple test contexts and updated expected output |
| src/usethis/_tool/impl/*.py | Refactored conditional logic to use elif/assert_never pattern across multiple tool implementations |
| src/usethis/_integrations/pre_commit/core.py | Applied elif/assert_never pattern for exhaustiveness |
| src/usethis/_tool/impl/ruff.py | Updated Ruff version to v0.14.9 |
| src/usethis/_tool/impl/pre_commit.py | Updated sync-with-uv version to v0.5.0 |
| src/usethis/_integrations/backend/uv/version.py | Updated fallback UV version to 0.9.18 |
| docs/requirements.txt | Updated pymdown-extensions to 10.19.1 |
CodSpeed Performance ReportMerging #1163 will not alter performanceComparing Summary
|
Don't assume the function will only be called on uv - previously the message said "Failed to run uv subprocess:". Now doesn't do that but gives the full call arguments
This is needed for the feature where uv will allow `[project]` to be missing from a `pyproject.toml` file
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
…lready exists
Also bump various versions, improve
call_subprocesserror messages, and bump minimum uv version