uv/crates
Charlie Marsh 3564e882d7
Ensure consistent indentation when adding dependencies (#14991)
## Summary

The basic problem here is that when we had multiple items in an inline
array, and that array expanded to multiple lines, we accidentally
changed the indentation part-way through due to how prefixes work in the
TOML.

Here's Claude's explanation of the root cause, which I find pretty
decent:

```
  Here's what happened step by step:

  1. First item ("iniconfig"): Has empty prefix "" → indentation_prefix stays None → uses default 4 spaces
  2. Second item ("ruff"): Has empty prefix "" → indentation_prefix stays None → uses default 4 spaces
  3. Third item ("typing-extensions"): Has prefix " " (single space from inline format) → indentation_prefix becomes
  Some(" ") → uses only 1 space!

  This produced:
  [dependency-groups]
  dev = [
      "iniconfig>=2.0.0",
      "ruff",
   "typing-extensions",  # ← Only 1 space instead of 4!
  ]

  Why the Third Item Had a Different Prefix

  In inline arrays like ["ruff", "typing-extensions"], the items are separated by commas and spaces. When parsed by
  the TOML library:
  - "ruff" has no prefix (it comes right after [)
  - "typing-extensions" has a single space prefix (the space after the comma)

  The Fix

  Moving the indentation calculation outside the loop ensures it's calculated only once:

  // Calculate indentation ONCE before the loop
  if let Some(first_item) = deps.iter().next() {
      let decor_prefix = /* get prefix from first item */
      indentation_prefix = (!decor_prefix.is_empty()).then_some(decor_prefix.to_string());
  }

  // Now use the same indentation for ALL items
  for item in deps.iter_mut() {
      // Apply consistent indentation to every item
  }

  This ensures all items get the same indentation (4 spaces by default when converting from inline arrays), producing
   the correct output:

  [dependency-groups]
  dev = [
      "iniconfig>=2.0.0",
      "ruff",
      "typing-extensions",  # ← Correct 4-space indentation
  ]

  The bug only affected arrays being converted from inline to multiline format, where different items might have
  different residual formatting from their inline representation.
```

Closes #14961.

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2025-07-31 11:50:05 +00:00
..
uv Ensure consistent indentation when adding dependencies (#14991) 2025-07-31 11:50:05 +00:00
uv-auth Use workspace dependencies for crate dev-dependencies (#14903) 2025-07-25 13:57:49 -05:00
uv-bench Add `extra-build-dependencies` (#14735) 2025-07-30 09:53:07 -05:00
uv-build Bump version to 0.8.4 (#14980) 2025-07-30 16:24:20 +00:00
uv-build-backend Fix incorrect file permissions in wheel packages (#14930) 2025-07-28 15:56:08 +02:00
uv-build-frontend Add `extra-build-dependencies` (#14735) 2025-07-30 09:53:07 -05:00
uv-cache Cache Python downloads by default in `python install` tests (#14326) 2025-07-28 17:33:57 +00:00
uv-cache-info Follow links when cache-key is a glob (#13438) 2025-07-14 11:35:34 -04:00
uv-cache-key Add `DisplaySafeUrl` newtype to prevent leaking of credentials by default (#13560) 2025-05-27 00:05:30 +02:00
uv-cli Support installing additional executables in `uv tool install` (#14014) 2025-07-30 14:50:24 -05:00
uv-client Use workspace dependencies for crate dev-dependencies (#14903) 2025-07-25 13:57:49 -05:00
uv-configuration Add `extra-build-dependencies` (#14735) 2025-07-30 09:53:07 -05:00
uv-console Fix rendering of `uv venv --clear` hint in bash (#14691) 2025-07-17 17:20:21 -05:00
uv-dev Split preview mode into separate feature flags (#14823) 2025-07-25 11:01:57 -05:00
uv-dirs Use workspace dependencies for crate dev-dependencies (#14903) 2025-07-25 13:57:49 -05:00
uv-dispatch Make the `BuildDispatch` interpreter method async (#14956) 2025-07-31 06:42:27 -05:00
uv-distribution Make the `BuildDispatch` interpreter method async (#14956) 2025-07-31 06:42:27 -05:00
uv-distribution-filename Use workspace dependencies for crate dev-dependencies (#14903) 2025-07-25 13:57:49 -05:00
uv-distribution-types Remove resolved TODO in `allowed_indexes` (#14912) 2025-07-26 04:04:28 +00:00
uv-extract Disallow writing symlinks outside the source distribution target directory (#12259) 2025-07-22 09:20:09 -04:00
uv-fs Copy entry points and Jupyter data directories into ephemeral environments (#14790) 2025-07-22 12:11:05 +00:00
uv-git Skip GitHub fast path when rate-limited (#13033) 2025-06-24 12:11:41 -07:00
uv-git-types make GitOid strict about parsing exactly 40 hex characters 2025-06-09 23:50:36 +00:00
uv-globfilter Use workspace dependencies for crate dev-dependencies (#14903) 2025-07-25 13:57:49 -05:00
uv-install-wheel Use workspace dependencies for crate dev-dependencies (#14903) 2025-07-25 13:57:49 -05:00
uv-installer Run `cargo update` (#14899) 2025-07-25 15:19:38 -05:00
uv-macros Bump MSRV to 1.85 and Edition 2024 (#13516) 2025-05-18 19:38:43 -04:00
uv-metadata only warn if CRC appears to be missing (#12722) 2025-04-07 12:49:05 -05:00
uv-normalize Move dependency group normalization into specification (#14757) 2025-07-20 14:13:27 -04:00
uv-once-map Bump MSRV to 1.84 (#12670) 2025-04-04 11:49:26 -04:00
uv-options-metadata Implement `PartialEq` for `OptionSet` (#14765) 2025-07-20 18:17:07 -04:00
uv-pep440 Add `extra-build-dependencies` (#14735) 2025-07-30 09:53:07 -05:00
uv-pep508 Implement `CacheKey` for all `Pep508Url` variants (#14978) 2025-07-30 10:44:06 -05:00
uv-performance-memory-allocator Update Rust crate mimalloc to v0.1.47 (#14207) 2025-06-23 12:07:09 +02:00
uv-platform Split platform detection code into a dedicated `uv-platform` crate (#14918) 2025-07-28 14:12:04 -05:00
uv-platform-tags Extend wheel filtering to Android tags (#14977) 2025-07-30 15:26:44 +00:00
uv-publish Use workspace dependencies for crate dev-dependencies (#14903) 2025-07-25 13:57:49 -05:00
uv-pypi-types Implement `CacheKey` for all `Pep508Url` variants (#14978) 2025-07-30 10:44:06 -05:00
uv-python Split platform detection code into a dedicated `uv-platform` crate (#14918) 2025-07-28 14:12:04 -05:00
uv-redacted Avoid writing redacted credentials to tool receipt (#14855) 2025-07-23 16:01:10 -04:00
uv-requirements Support `extras` and `dependency_groups` markers on `uv pip install` and `uv pip sync` (#14755) 2025-07-21 12:48:47 +00:00
uv-requirements-txt Use workspace dependencies for crate dev-dependencies (#14903) 2025-07-25 13:57:49 -05:00
uv-resolver Extend wheel filtering to Android tags (#14977) 2025-07-30 15:26:44 +00:00
uv-scripts Add `extra-build-dependencies` (#14735) 2025-07-30 09:53:07 -05:00
uv-settings Add `extra-build-dependencies` (#14735) 2025-07-30 09:53:07 -05:00
uv-shell Bump MSRV to 1.85 and Edition 2024 (#13516) 2025-05-18 19:38:43 -04:00
uv-small-str Update schemars 1.0.0 (#13693) 2025-06-24 21:43:31 +02:00
uv-state Bump MSRV to 1.85 and Edition 2024 (#13516) 2025-05-18 19:38:43 -04:00
uv-static Add `UV_` prefix to installer environment variables (#14964) 2025-07-30 01:24:59 +00:00
uv-tool Support installing additional executables in `uv tool install` (#14014) 2025-07-30 14:50:24 -05:00
uv-torch Add auto-detection for Intel GPUs (#14386) 2025-07-09 13:31:08 +00:00
uv-trampoline Support transparent Python patch version upgrades (#13954) 2025-06-20 16:17:13 +02:00
uv-trampoline-builder Use workspace dependencies for crate dev-dependencies (#14903) 2025-07-25 13:57:49 -05:00
uv-types Make the `BuildDispatch` interpreter method async (#14956) 2025-07-31 06:42:27 -05:00
uv-version Bump version to 0.8.4 (#14980) 2025-07-30 16:24:20 +00:00
uv-virtualenv Split preview mode into separate feature flags (#14823) 2025-07-25 11:01:57 -05:00
uv-warnings Better warning chain styling (#14934) 2025-07-28 16:23:39 +00:00
uv-workspace Ensure consistent indentation when adding dependencies (#14991) 2025-07-31 11:50:05 +00:00
README.md Link to Dependency specifiers instead of PEP 508 (#8411) 2024-10-21 14:43:38 -04:00

README.md

Crates

uv-bench

Functionality for benchmarking uv.

uv-cache-key

Generic functionality for caching paths, URLs, and other resources across platforms.

uv-distribution-filename

Parse built distribution (wheel) and source distribution (sdist) filenames to extract structured metadata.

uv-distribution-types

Abstractions for representing built distributions (wheels) and source distributions (sdists), and the sources from which they can be downloaded.

uv-install-wheel-rs

Install built distributions (wheels) into a virtual environment.

uv-once-map

A waitmap-like concurrent hash map for executing tasks exactly once.

uv-pep440-rs

Utilities for interacting with Python version numbers and specifiers.

uv-pep508-rs

Utilities for parsing and evaluating dependency specifiers, previously known as PEP 508.

uv-platform-tags

Functionality for parsing and inferring Python platform tags as per PEP 425.

uv-cli

Command-line interface for the uv package manager.

uv-build-frontend

A PEP 517-compatible build frontend for uv.

uv-cache

Functionality for caching Python packages and associated metadata.

uv-client

Client for interacting with PyPI-compatible HTTP APIs.

uv-dev

Development utilities for uv.

uv-dispatch

A centralized struct for resolving and building source distributions in isolated environments. Implements the traits defined in uv-types.

uv-distribution

Client for interacting with built distributions (wheels) and source distributions (sdists). Capable of fetching metadata, distribution contents, etc.

uv-extract

Utilities for extracting files from archives.

uv-fs

Utilities for interacting with the filesystem.

uv-git

Functionality for interacting with Git repositories.

uv-installer

Functionality for installing Python packages into a virtual environment.

uv-python

Functionality for detecting and leveraging the current Python interpreter.

uv-normalize

Normalize package and extra names as per Python specifications.

uv-requirements

Utilities for reading package requirements from pyproject.toml and requirements.txt files.

uv-resolver

Functionality for resolving Python packages and their dependencies.

uv-shell

Utilities for detecting and manipulating shell environments.

uv-types

Shared traits for uv, to avoid circular dependencies.

uv-pypi-types

General-purpose type definitions for types used in PyPI-compatible APIs.

uv-virtualenv

A venv replacement to create virtual environments in Rust.

uv-warnings

User-facing warnings for uv.

uv-workspace

Workspace abstractions for uv.

uv-requirements-txt

Functionality for parsing requirements.txt files.