Warn when duplicate index names found in single file#11824
Merged
charliermarsh merged 2 commits intoastral-sh:mainfrom Feb 27, 2025
Merged
Warn when duplicate index names found in single file#11824charliermarsh merged 2 commits intoastral-sh:mainfrom
charliermarsh merged 2 commits intoastral-sh:mainfrom
Conversation
dee1096 to
26b0be0
Compare
a6a548a to
74e8677
Compare
74e8677 to
ff71521
Compare
charliermarsh
approved these changes
Feb 27, 2025
f45e113 to
0827d5c
Compare
Member
|
Thanks! |
charliermarsh
added a commit
that referenced
this pull request
Feb 28, 2025
## Summary A small follow-up to #11824.
loic-lescoat
pushed a commit
to loic-lescoat/uv
that referenced
this pull request
Mar 2, 2025
<!-- Thank you for contributing to uv! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? - Does this pull request include references to any relevant issues? --> ## Summary This pull request introduces validation for unique index names in the `tool.uv.index` field and adds corresponding tests to ensure the functionality. The most important changes include adding a custom deserializer function, updating the `ToolUv` struct to use the new deserializer, and adding tests to verify the behavior. Validation and deserialization: * [`crates/uv-workspace/src/pyproject.rs`](diffhunk://#diff-e12cd255985adfd45ab06f398cb420d2f543841ccbeea4175ccf827aa9215b9dR283-R311): Added a custom deserializer function `deserialize_index_vec` to validate that index names in the `tool.uv.index` field are unique. * [`crates/uv-workspace/src/pyproject.rs`](diffhunk://#diff-e12cd255985adfd45ab06f398cb420d2f543841ccbeea4175ccf827aa9215b9dR374): Updated the `ToolUv` struct to use the `deserialize_index_vec` function for the `index` field. Testing: * [`crates/uv/tests/it/lock.rs`](diffhunk://#diff-82edd36151736f44055f699a34c8b19a63ffc4cf3c86bf5fb34d69f8ac88a957R15336): Added a test `lock_repeat_named_index` to verify that duplicate index names result in an error. [[1]](diffhunk://#diff-82edd36151736f44055f699a34c8b19a63ffc4cf3c86bf5fb34d69f8ac88a957R15336) [[2]](diffhunk://#diff-82edd36151736f44055f699a34c8b19a63ffc4cf3c86bf5fb34d69f8ac88a957R15360-R15402) * [`crates/uv/tests/it/lock.rs`](diffhunk://#diff-82edd36151736f44055f699a34c8b19a63ffc4cf3c86bf5fb34d69f8ac88a957R15360-R15402): Added a test `lock_unique_named_index` to verify that unique index names result in successful lock file generation. Schema update: * [`uv.schema.json`](diffhunk://#diff-c669473b258a19ba6d3557d0369126773b68b27171989f265333a77bc5cb935bR205): Updated the schema to set the default value of the `index` field to `null`. Fixes astral-sh#11804 ## Test Plan ### Steps to reproduce and verify the fix: 1. Clone the repository and checkout the feature branch ```bash git clone https://github.com/astral-sh/uv.git cd uv git checkout feature/warn-duplicate-index-names ``` 2. Build the modified binary ```bash cargo build ``` 3. Create a test project using the system installed uv ```bash uv init uv-test cd uv-test ``` 4. Manually edit pyproject.toml to add duplicate index names ```toml [[tool.uv.index]] name = "alpha_b" url = "<omitted>" [[tool.uv.index]] name = "alpha_b" url = "<omitted>" ``` 5. Try to add a package using the modified binary ```bash ../target/debug/uv add numpy ``` ### Results Before: use release binary  After: use self build binary  Now when attempting to use a pyproject.toml with duplicate index names, the modified binary correctly detects the issue and produces an error message: ``` error: Failed to parse: `pyproject.toml` Caused by: TOML parse error at line 9, column 1 | 9 | [[tool.uv.index]] | ^^^^^^^^^^^^^^^^^ duplicate index name `alpha_b` ``` --------- Co-authored-by: Charlie Marsh <[email protected]>
loic-lescoat
pushed a commit
to loic-lescoat/uv
that referenced
this pull request
Mar 2, 2025
## Summary A small follow-up to astral-sh#11824.
tmeijn
pushed a commit
to tmeijn/dotfiles
that referenced
this pull request
Mar 6, 2025
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [astral-sh/uv](https://github.com/astral-sh/uv) | patch | `0.6.3` -> `0.6.4` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>astral-sh/uv (astral-sh/uv)</summary> ### [`v0.6.4`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#064) [Compare Source](astral-sh/uv@0.6.3...0.6.4) ##### Enhancements - Upgrade pypy3.10 to v7.3.19 ([#​11814](astral-sh/uv#11814)) - Allow configuring log verbosity from the CLI (i.e., `-vvv`) ([#​11758](astral-sh/uv#11758)) - Warn when duplicate index names found in single file ([#​11824](astral-sh/uv#11824)) ##### Bug fixes - Always store registry index on resolution packages ([#​11815](astral-sh/uv#11815)) - Avoid error on relative paths in `uv tool uninstall` ([#​11889](astral-sh/uv#11889)) - Avoid silently dropping errors in directory enumeration ([#​11890](astral-sh/uv#11890)) - Disable interactive git terminal prompts during fetches ([#​11744](astral-sh/uv#11744)) - Discover Windows registry (PEP 514) Python versions across 32/64-bit ([#​11801](astral-sh/uv#11801)) - Don't panic on Ctrl-C in confirm prompt ([#​11706](astral-sh/uv#11706)) - Fix non-directory in workspace on Windows ([#​11833](astral-sh/uv#11833)) - Make interpreter caching robust to OS upgrades ([#​11875](astral-sh/uv#11875)) - Respect `include-system-site-packages` in layered environments ([#​11873](astral-sh/uv#11873)) - Suggest `uv tool update-shell` in PowerShell ([#​11846](astral-sh/uv#11846)) - Update code page to `65001` before setting environment variables in virtual environments ([#​11831](astral-sh/uv#11831)) - Use hash instead of full wheel name in wheels bucket ([#​11738](astral-sh/uv#11738)) - Fix version string truncation while generating cache_key ([#​11830](astral-sh/uv#11830)) - Explicitly handle ctrl-c in confirmation prompt instead of using a signal handler ([#​11897](astral-sh/uv#11897)) ##### Performance - Avoid cloning to string when creating cache path ([#​11772](astral-sh/uv#11772)) - Avoid redundant clones in version containment check ([#​11767](astral-sh/uv#11767)) - Avoid string allocation when enumerating tool names ([#​11910](astral-sh/uv#11910)) - Avoid using owned `String` for package name constructors ([#​11768](astral-sh/uv#11768)) - Avoid using owned `String` in deserializers ([#​11764](astral-sh/uv#11764)) - Migrate to `zlib-rs` (again) ([#​11894](astral-sh/uv#11894)) - Remove unnecessary clones when adding package names ([#​11771](astral-sh/uv#11771)) - Skip unquote allocation for non-quoted strings ([#​11813](astral-sh/uv#11813)) - Use `SmallString` for filenames and URLs ([#​11765](astral-sh/uv#11765)) - Use a Boxed slice for version specifiers ([#​11766](astral-sh/uv#11766)) - Use matches over contains for extra value parsing ([#​11770](astral-sh/uv#11770)) ##### Documentation - Avoid fallback to PyPI in mixed CPU/CUDA example ([#​11115](astral-sh/uv#11115)) - Docs: Clarify that setting cache-keys overrides defaults ([#​11895](astral-sh/uv#11895)) - Document our MSRV policy ([#​11898](astral-sh/uv#11898)) - Fix reference to macOS cache path ([#​11845](astral-sh/uv#11845)) - Fix typo in `no_default_groups` documentation and changelog ([#​11928](astral-sh/uv#11928)) - Update the "Locking and syncing" page ([#​11647](astral-sh/uv#11647)) - Update alternative indexes documentation to use new interface ([#​10826](astral-sh/uv#10826)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4xODUuMCIsInVwZGF0ZWRJblZlciI6IjM5LjE4NS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This pull request introduces validation for unique index names in the
tool.uv.indexfield and adds corresponding tests to ensure the functionality. The most important changes include adding a custom deserializer function, updating theToolUvstruct to use the new deserializer, and adding tests to verify the behavior.Validation and deserialization:
crates/uv-workspace/src/pyproject.rs: Added a custom deserializer functiondeserialize_index_vecto validate that index names in thetool.uv.indexfield are unique.crates/uv-workspace/src/pyproject.rs: Updated theToolUvstruct to use thedeserialize_index_vecfunction for theindexfield.Testing:
crates/uv/tests/it/lock.rs: Added a testlock_repeat_named_indexto verify that duplicate index names result in an error. [1] [2]crates/uv/tests/it/lock.rs: Added a testlock_unique_named_indexto verify that unique index names result in successful lock file generation.Schema update:
uv.schema.json: Updated the schema to set the default value of theindexfield tonull.Fixes #11804
Test Plan
Steps to reproduce and verify the fix:
Clone the repository and checkout the feature branch
git clone https://github.com/astral-sh/uv.git cd uv git checkout feature/warn-duplicate-index-namesBuild the modified binary
Create a test project using the system installed uv
uv init uv-test cd uv-testManually edit pyproject.toml to add duplicate index names
Try to add a package using the modified binary
Results
Before: use release binary

After: use self build binary

Now when attempting to use a pyproject.toml with duplicate index names, the modified binary correctly detects the issue and produces an error message: