Preserve order of dependencies which are sorted naively#13334
Merged
charliermarsh merged 1 commit intoastral-sh:mainfrom May 7, 2025
Merged
Preserve order of dependencies which are sorted naively#13334charliermarsh merged 1 commit intoastral-sh:mainfrom
charliermarsh merged 1 commit intoastral-sh:mainfrom
Conversation
0c83e9b to
7951233
Compare
The prior implementation only looks for dependencies which are sorted by name then specifier. If dependencies are sorted using the typical "sort lines" operation in text editors, then `flask-wtf>=1.2.1` is sorted before `flask>=3.0.2`.
7951233 to
5a1878a
Compare
charliermarsh
added a commit
that referenced
this pull request
May 10, 2025
This follows on from #13334 to fix another case. <!-- 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 If a dependency group contained any `{ include-group = "..." }` entries, the sort detection would bail out. The root cause of the problem was gating the sort detection behind `deps.iter().all(Value::is_str)`. A public code search reveals that keeping include-groups at the top is by far the most common, but keeping them at the bottom isn't uncommon. In both of these cases, uv will now preserve the convention that is in use. Unless I've missed it, I don't think uv supports `uv add`ing an include-group, and so that wasn't tested here. ## Test Plan cargo test --------- Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
netbsd-srcmastr
pushed a commit
to NetBSD/pkgsrc
that referenced
this pull request
May 18, 2025
## 0.7.5 ### Bug fixes - Support case-sensitive module discovery in the build backend ([#13468](astral-sh/uv#13468)) - Bump Simple cache bucket to v16 ([#13498](astral-sh/uv#13498)) - Don't error when the script is too short for the buffer ([#13488](astral-sh/uv#13488)) - Add missing word in "script not supported" error ([#13483](astral-sh/uv#13483)) ## 0.7.4 ### Enhancements - Add more context to external errors ([#13351](astral-sh/uv#13351)) - Align indentation of long arguments ([#13394](astral-sh/uv#13394)) - Preserve order of dependencies which are sorted naively ([#13334](astral-sh/uv#13334)) - Align progress bars by largest name length ([#13266](astral-sh/uv#13266)) - Reinstall local packages in `uv add` ([#13462](astral-sh/uv#13462)) - Rename `--raw-sources` to `--raw` ([#13348](astral-sh/uv#13348)) - Show 'Downgraded' when `self update` is used to install an older version ([#13340](astral-sh/uv#13340)) - Suggest `uv self update` if required uv version is newer ([#13305](astral-sh/uv#13305)) - Add 3.14 beta images to uv Docker images ([#13390](astral-sh/uv#13390)) - Add comma after "i.e." in Conda environment error ([#13423](astral-sh/uv#13423)) - Be more precise in unpinned packages warning ([#13426](astral-sh/uv#13426)) - Fix detection of sorted dependencies when include-group is used ([#13354](astral-sh/uv#13354)) - Fix display of HTTP responses in trace logs for retry of errors ([#13339](astral-sh/uv#13339)) - Log skip reasons during Python installation key interpreter match checks ([#13472](astral-sh/uv#13472)) - Redact credentials when displaying URLs ([#13333](astral-sh/uv#13333)) ### Bug fixes - Avoid erroring on `pylock.toml` dependency entries ([#13384](astral-sh/uv#13384)) - Avoid panics for cannot-be-a-base URLs ([#13406](astral-sh/uv#13406)) - Ensure cached realm credentials are applied if no password is found for index URL ([#13463](astral-sh/uv#13463)) - Fix `.tgz` parsing to respect true extension ([#13382](astral-sh/uv#13382)) - Fix double self-dependency ([#13366](astral-sh/uv#13366)) - Reject `pylock.toml` in `uv add -r` ([#13421](astral-sh/uv#13421)) - Retain dot-separated wheel tags during cache prune ([#13379](astral-sh/uv#13379)) - Retain trailing comments after PEP 723 metadata block ([#13460](astral-sh/uv#13460)) ### Documentation - Use "export" instead of "install" in `uv export` arguments ([#13430](astral-sh/uv#13430)) - Remove extra newline ([#13461](astral-sh/uv#13461)) ### Preview features - Build backend: Normalize glob paths ([#13465](astral-sh/uv#13465))
tmeijn
pushed a commit
to tmeijn/dotfiles
that referenced
this pull request
May 19, 2025
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [astral-sh/uv](https://github.com/astral-sh/uv) | patch | `0.7.3` -> `0.7.5` | 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.7.5`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#075) [Compare Source](astral-sh/uv@0.7.4...0.7.5) ##### Bug fixes - Support case-sensitive module discovery in the build backend ([#​13468](astral-sh/uv#13468)) - Bump Simple cache bucket to v16 ([#​13498](astral-sh/uv#13498)) - Don't error when the script is too short for the buffer ([#​13488](astral-sh/uv#13488)) - Add missing word in "script not supported" error ([#​13483](astral-sh/uv#13483)) ### [`v0.7.4`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#074) [Compare Source](astral-sh/uv@0.7.3...0.7.4) ##### Enhancements - Add more context to external errors ([#​13351](astral-sh/uv#13351)) - Align indentation of long arguments ([#​13394](astral-sh/uv#13394)) - Preserve order of dependencies which are sorted naively ([#​13334](astral-sh/uv#13334)) - Align progress bars by largest name length ([#​13266](astral-sh/uv#13266)) - Reinstall local packages in `uv add` ([#​13462](astral-sh/uv#13462)) - Rename `--raw-sources` to `--raw` ([#​13348](astral-sh/uv#13348)) - Show 'Downgraded' when `self update` is used to install an older version ([#​13340](astral-sh/uv#13340)) - Suggest `uv self update` if required uv version is newer ([#​13305](astral-sh/uv#13305)) - Add 3.14 beta images to uv Docker images ([#​13390](astral-sh/uv#13390)) - Add comma after "i.e." in Conda environment error ([#​13423](astral-sh/uv#13423)) - Be more precise in unpinned packages warning ([#​13426](astral-sh/uv#13426)) - Fix detection of sorted dependencies when include-group is used ([#​13354](astral-sh/uv#13354)) - Fix display of HTTP responses in trace logs for retry of errors ([#​13339](astral-sh/uv#13339)) - Log skip reasons during Python installation key interpreter match checks ([#​13472](astral-sh/uv#13472)) - Redact credentials when displaying URLs ([#​13333](astral-sh/uv#13333)) ##### Bug fixes - Avoid erroring on `pylock.toml` dependency entries ([#​13384](astral-sh/uv#13384)) - Avoid panics for cannot-be-a-base URLs ([#​13406](astral-sh/uv#13406)) - Ensure cached realm credentials are applied if no password is found for index URL ([#​13463](astral-sh/uv#13463)) - Fix `.tgz` parsing to respect true extension ([#​13382](astral-sh/uv#13382)) - Fix double self-dependency ([#​13366](astral-sh/uv#13366)) - Reject `pylock.toml` in `uv add -r` ([#​13421](astral-sh/uv#13421)) - Retain dot-separated wheel tags during cache prune ([#​13379](astral-sh/uv#13379)) - Retain trailing comments after PEP 723 metadata block ([#​13460](astral-sh/uv#13460)) ##### Documentation - Use "export" instead of "install" in `uv export` arguments ([#​13430](astral-sh/uv#13430)) - Remove extra newline ([#​13461](astral-sh/uv#13461)) ##### Preview features - Build backend: Normalize glob paths ([#​13465](astral-sh/uv#13465)) </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:eyJjcmVhdGVkSW5WZXIiOiI0MC4xMS4xOSIsInVwZGF0ZWRJblZlciI6IjQwLjEzLjAiLCJ0YXJnZXRCcmFuY2giOiJtYWluIiwibGFiZWxzIjpbIlJlbm92YXRlIEJvdCJdfQ==-->
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
The prior implementation only looks for dependencies which are sorted by name then specifier.
I knew uv was meant to preserve sorted dependencies, but it never seemed to work for me.
I've always used the "sort lines" feature of PyCharm/Sublime to sort these lists, and I guess I'm not the only one. In such a case,
flask-wtf>=1.2.1is sorted beforeflask>=3.0.2.After digging into the code I realised what was happening, hence this merge request.
Maybe there's a tool I'm not aware of that people are using to sort dependencies "properly", or are doing it by hand, but I think this is worth supporting.
Relevant issues: #9076, #10738
Test Plan
cargo test