Skip to content

feat: detect uv Python projects - #194

Open
QueryPlanner wants to merge 2 commits into
tbillington:masterfrom
QueryPlanner:feat/uv-project-detection
Open

feat: detect uv Python projects#194
QueryPlanner wants to merge 2 commits into
tbillington:masterfrom
QueryPlanner:feat/uv-project-detection

Conversation

@QueryPlanner

@QueryPlanner QueryPlanner commented Aug 26, 2026

Copy link
Copy Markdown

What

Add uv project detection using uv.lock and pyproject.toml.

Why

Python detection currently requires a .py file at the project root. uv projects with source files in a subdirectory are missed, leaving root-level caches undiscovered.

How

  • Remove an existing redundant reference in CLI formatting that Rust 1.98 Clippy rejects. CLI output remains unchanged.
  • Recognize both marker filenames as the existing Python project type in scanning and direct cleanup.
  • Require regular files for the new direct-cleanup markers so same-named directories or symlinks cannot trigger cleanup.
  • Reuse the existing Python cache directories. Preserve .venv, following the policy established in dont remove .venv for python #182.
  • Recognize any pyproject.toml, including files with [tool.uv], without adding a TOML parser or dependencies.
  • Document that cleanup applies to cache directories at the detected project root. Recursive cache cleanup and custom uv environments are outside this change.

Tests

  • cargo fmt --all -- --check
  • cargo clippy --tests --locked --offline -- -D warnings
  • cargo clippy -p kondo-lib --tests --locked --offline -- -D warnings
  • cargo test --all --locked --offline: 1 unit test and 4 integration tests pass.
  • cargo build --locked --offline
  • Regression tests cover both markers, generic and uv pyproject files, multiple markers, legacy Python scanning, cache sizes, both cleanup APIs, directory-marker rejection, and preservation of source files, markers, and a non-empty .venv.
  • The two feature regression tests fail against an isolated copy of unchanged upstream.
  • CLI dry-run detects both marker-only fixture roots, excludes .venv, ignores directory/symlink markers, and preserves all fixture contents.
  • LLVM instrumentation covers all 6 added detection executable lines. Whole-library coverage is 233/370 lines; this is not a claim of full repository coverage.

Local checks initially ran on macOS arm64 with Rust 1.96.0. After CI exposed a newer Clippy lint, validation was repeated with Rust 1.98.0, matching CI. The original failure was reproduced locally before the patch, and CLI dry-run output was compared before and after it. The workspace emits an existing future-compatibility warning for the transitive block dependency; all commands above pass.

Related Issues

Closes #188.

The uv project layout is documented at https://docs.astral.sh/uv/concepts/projects/layout/.

- Recognize uv.lock and pyproject.toml as Python project markers
- Require regular marker files in direct cleanup
- Preserve Python virtual environments and document cache scope
- Test detection, cache cleanup, and retained project files
- Remove a redundant borrow rejected by Rust 1.98 Clippy
- Preserve project-name output in CLI listings
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.

Support for uv (Python package manager) projects

1 participant