Repository navigation
Conversation
64a8e16 to
0c1b97a
Compare
Merging this PR will not alter performance
Comparing Footnotes
|
b01dd36 to
db1da3a
Compare
| if let Some(warning) = format_tilde_requires_python_warning(&requires_python) { | ||
| warn_user_once!("{warning}"); |
There was a problem hiding this comment.
[P2] Preserve per-source deduplication when aggregating warnings
When a project and its selected dev group both declare requires-python = "~=3.12", normal uv sync calls this function with groups during environment discovery, then without groups through LockTarget::requires_python during locking. The first call emits the aggregate warning; the second emits the single-project warning. Because warn_user_once! deduplicates complete messages, the project declaration is now reported twice. Previously its individual warning was suppressed on the second call. Deduplicate declarations before formatting the aggregate, and cover this two-stage path with a sync integration snapshot.
| CompatibleProjectPython, ProjectPythonRequest, ProjectPythonRequirement, PythonRequestSource, | ||
| PythonRequirementConflicts, PythonRequirementSource, find_requires_python, | ||
| format_requires_python_sources, | ||
| format_requires_python_sources, format_tilde_requires_python_warning, |
There was a problem hiding this comment.
[P3] Keep the warning formatter private to its owning crate
The only consumer of this export outside project.rs is the new test module in uv-project-commands. This exposes an implementation detail solely for testing and places its regression tests in a different crate from the implementation. The existing lock_requires_python_compatible_specifier integration snapshot already covers the single-project warning and two excluded forms. Extend the command snapshot coverage for consolidation and selected groups, then keep this helper private; that also verifies warning emission rather than only the returned string.
db1da3a to
a4b27db
Compare
| Some((source.clone(), specifiers.clone())) | ||
| }) | ||
| .collect(); |
There was a problem hiding this comment.
[P3] Pass filtered tilde specifiers directly to the formatter
The caller has already checked the specifier count, converted to TildeVersionSpecifier, and excluded patch versions. Rebuilding RequiresPythonSources here clones the declarations and specifiers solely for the formatter to repeat those same checks and build another collection. This creates two places to maintain warning eligibility. Collect borrowed (source, specifier) entries and pass that slice to the formatter so it only handles rendering.
| - `example`: `~=3.12` is interpreted as `>=3.12, <4`; use `~=3.12.[X]` to constrain the version as `>=3.12.[X], <3.13` | ||
| - `example:dev`: `~=3.12` is interpreted as `>=3.12, <4`; use `~=3.12.[X]` to constrain the version as `>=3.12.[X], <3.13` |
There was a problem hiding this comment.
[P3] Keep suggested patch versions visible in the snapshot
With test_context!("3.12"), the context filters replace every 3.12.<digits> with 3.12.[X], hiding the deterministic .0 that this diagnostic recommends. The new multi-source rendering could incorrectly suggest ~=3.12.1 and this snapshot would still pass. Use declarations such as ~=3.11 with the existing Python 3.12 context so the suggested patch and bounds remain visible without requiring another interpreter.
Workspaces with several
requires-python = "~=3.12"declarations repeat the full ambiguity warning for each package or dependency group. Consolidate the affected sources into one warning while retaining the existing text for a single source. Warning eligibility and the computed Python range are unchanged. This implements the consolidation suggested in astral-sh#14422.