Skip to content

Don't infer uv is used if there's no lockfile but pyproject.toml a…#1163

Merged
nathanjmcdougall merged 8 commits intomainfrom
1162-infer-that-uv-isnt-used-if-theres-no-lockfile-but-pyprojecttoml-already-exists
Dec 17, 2025
Merged

Don't infer uv is used if there's no lockfile but pyproject.toml a…#1163
nathanjmcdougall merged 8 commits intomainfrom
1162-infer-that-uv-isnt-used-if-theres-no-lockfile-but-pyprojecttoml-already-exists

Conversation

@nathanjmcdougall
Copy link
Copy Markdown
Collaborator

@nathanjmcdougall nathanjmcdougall commented Nov 22, 2025

…lready exists

Also bump various versions, improve call_subprocess error messages, and bump minimum uv version

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 uv when pyproject.toml doesn't exist yet
  • Updated tests to explicitly set backend=BackendEnum.uv in contexts where uv should be used
  • Refactored conditional logic in tool implementations to use elif/assert_never pattern 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-hq
Copy link
Copy Markdown

codspeed-hq bot commented Dec 17, 2025

CodSpeed Performance Report

Merging #1163 will not alter performance

Comparing 1162-infer-that-uv-isnt-used-if-theres-no-lockfile-but-pyprojecttoml-already-exists (72bd29b) with main (1def16b)

Summary

✅ 2 untouched

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
Copy link
Copy Markdown

codecov bot commented Dec 17, 2025

Codecov Report

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

Files with missing lines Patch % Lines
src/usethis/_tool/impl/ruff.py 60.00% 2 Missing ⚠️
src/usethis/_integrations/backend/dispatch.py 91.66% 1 Missing ⚠️
src/usethis/_tool/impl/deptry.py 0.00% 1 Missing ⚠️
src/usethis/_tool/impl/pyproject_fmt.py 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@nathanjmcdougall nathanjmcdougall merged commit 40431e5 into main Dec 17, 2025
19 of 20 checks passed
@nathanjmcdougall nathanjmcdougall deleted the 1162-infer-that-uv-isnt-used-if-theres-no-lockfile-but-pyprojecttoml-already-exists branch December 17, 2025 12:41
This was referenced Dec 22, 2025
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.

Infer that uv isn't used if there's no lockfile but pyproject.toml already exists

2 participants