mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 21:35:00 +00:00
Fix pre-release exclusive comparison operator in uv-pep440 (#12836)
Some checks failed
CI / lint (push) Has been cancelled
CI / Determine changes (push) Has been cancelled
CI / cargo shear (push) Has been cancelled
CI / typos (push) Has been cancelled
CI / mkdocs (push) Has been cancelled
CI / check system | pypy on ubuntu (push) Has been cancelled
CI / check system | pyston (push) Has been cancelled
CI / check system | conda3.8 on windows x86-64 (push) Has been cancelled
CI / build binary | windows aarch64 (push) Has been cancelled
CI / cargo clippy | ubuntu (push) Has been cancelled
CI / cargo clippy | windows (push) Has been cancelled
CI / cargo dev generate-all (push) Has been cancelled
CI / cargo test | ubuntu (push) Has been cancelled
CI / cargo test | macos (push) Has been cancelled
CI / cargo test | windows (push) Has been cancelled
CI / check windows trampoline | aarch64 (push) Has been cancelled
CI / check windows trampoline | i686 (push) Has been cancelled
CI / integration test | pypy on ubuntu (push) Has been cancelled
CI / check windows trampoline | x86_64 (push) Has been cancelled
CI / test windows trampoline | i686 (push) Has been cancelled
CI / test windows trampoline | x86_64 (push) Has been cancelled
CI / build binary | linux libc (push) Has been cancelled
CI / build binary | linux musl (push) Has been cancelled
CI / build binary | macos aarch64 (push) Has been cancelled
CI / build binary | macos x86_64 (push) Has been cancelled
CI / build binary | windows x86_64 (push) Has been cancelled
CI / cargo build (msrv) (push) Has been cancelled
CI / build binary | freebsd (push) Has been cancelled
CI / ecosystem test | pydantic/pydantic-core (push) Has been cancelled
CI / ecosystem test | prefecthq/prefect (push) Has been cancelled
CI / integration test | pypy on windows (push) Has been cancelled
CI / ecosystem test | pallets/flask (push) Has been cancelled
CI / smoke test | linux (push) Has been cancelled
CI / check system | alpine (push) Has been cancelled
CI / smoke test | macos (push) Has been cancelled
CI / smoke test | windows x86_64 (push) Has been cancelled
CI / smoke test | windows aarch64 (push) Has been cancelled
CI / integration test | conda on ubuntu (push) Has been cancelled
CI / integration test | deadsnakes python3.9 on ubuntu (push) Has been cancelled
CI / integration test | free-threaded on linux (push) Has been cancelled
CI / integration test | free-threaded on windows (push) Has been cancelled
CI / integration test | graalpy on ubuntu (push) Has been cancelled
CI / integration test | graalpy on windows (push) Has been cancelled
CI / integration test | github actions (push) Has been cancelled
CI / integration test | free-threaded python on github actions (push) Has been cancelled
CI / integration test | determine publish changes (push) Has been cancelled
CI / integration test | uv publish (push) Has been cancelled
CI / integration test | uv_build (push) Has been cancelled
CI / check cache | ubuntu (push) Has been cancelled
CI / check cache | macos aarch64 (push) Has been cancelled
CI / check system | python on debian (push) Has been cancelled
CI / check system | python on fedora (push) Has been cancelled
CI / check system | python on ubuntu (push) Has been cancelled
CI / check system | python on opensuse (push) Has been cancelled
CI / check system | python on rocky linux 8 (push) Has been cancelled
CI / check system | python on rocky linux 9 (push) Has been cancelled
CI / check system | python on macos aarch64 (push) Has been cancelled
CI / check system | homebrew python on macos aarch64 (push) Has been cancelled
CI / check system | python on macos x86-64 (push) Has been cancelled
CI / check system | python3.10 on windows x86-64 (push) Has been cancelled
CI / check system | python3.10 on windows x86 (push) Has been cancelled
CI / check system | python3.13 on windows x86-64 (push) Has been cancelled
CI / check system | x86-64 python3.13 on windows aarch64 (push) Has been cancelled
CI / check system | windows registry (push) Has been cancelled
CI / check system | python3.12 via chocolatey (push) Has been cancelled
CI / check system | python3.9 via pyenv (push) Has been cancelled
CI / check system | python3.13 (push) Has been cancelled
CI / check system | conda3.11 on macos aarch64 (push) Has been cancelled
CI / check system | conda3.8 on macos aarch64 (push) Has been cancelled
CI / check system | conda3.11 on linux x86-64 (push) Has been cancelled
CI / check system | conda3.8 on linux x86-64 (push) Has been cancelled
CI / check system | conda3.11 on windows x86-64 (push) Has been cancelled
CI / check system | amazonlinux (push) Has been cancelled
CI / check system | embedded python3.10 on windows x86-64 (push) Has been cancelled
CI / benchmarks (push) Has been cancelled
Some checks failed
CI / lint (push) Has been cancelled
CI / Determine changes (push) Has been cancelled
CI / cargo shear (push) Has been cancelled
CI / typos (push) Has been cancelled
CI / mkdocs (push) Has been cancelled
CI / check system | pypy on ubuntu (push) Has been cancelled
CI / check system | pyston (push) Has been cancelled
CI / check system | conda3.8 on windows x86-64 (push) Has been cancelled
CI / build binary | windows aarch64 (push) Has been cancelled
CI / cargo clippy | ubuntu (push) Has been cancelled
CI / cargo clippy | windows (push) Has been cancelled
CI / cargo dev generate-all (push) Has been cancelled
CI / cargo test | ubuntu (push) Has been cancelled
CI / cargo test | macos (push) Has been cancelled
CI / cargo test | windows (push) Has been cancelled
CI / check windows trampoline | aarch64 (push) Has been cancelled
CI / check windows trampoline | i686 (push) Has been cancelled
CI / integration test | pypy on ubuntu (push) Has been cancelled
CI / check windows trampoline | x86_64 (push) Has been cancelled
CI / test windows trampoline | i686 (push) Has been cancelled
CI / test windows trampoline | x86_64 (push) Has been cancelled
CI / build binary | linux libc (push) Has been cancelled
CI / build binary | linux musl (push) Has been cancelled
CI / build binary | macos aarch64 (push) Has been cancelled
CI / build binary | macos x86_64 (push) Has been cancelled
CI / build binary | windows x86_64 (push) Has been cancelled
CI / cargo build (msrv) (push) Has been cancelled
CI / build binary | freebsd (push) Has been cancelled
CI / ecosystem test | pydantic/pydantic-core (push) Has been cancelled
CI / ecosystem test | prefecthq/prefect (push) Has been cancelled
CI / integration test | pypy on windows (push) Has been cancelled
CI / ecosystem test | pallets/flask (push) Has been cancelled
CI / smoke test | linux (push) Has been cancelled
CI / check system | alpine (push) Has been cancelled
CI / smoke test | macos (push) Has been cancelled
CI / smoke test | windows x86_64 (push) Has been cancelled
CI / smoke test | windows aarch64 (push) Has been cancelled
CI / integration test | conda on ubuntu (push) Has been cancelled
CI / integration test | deadsnakes python3.9 on ubuntu (push) Has been cancelled
CI / integration test | free-threaded on linux (push) Has been cancelled
CI / integration test | free-threaded on windows (push) Has been cancelled
CI / integration test | graalpy on ubuntu (push) Has been cancelled
CI / integration test | graalpy on windows (push) Has been cancelled
CI / integration test | github actions (push) Has been cancelled
CI / integration test | free-threaded python on github actions (push) Has been cancelled
CI / integration test | determine publish changes (push) Has been cancelled
CI / integration test | uv publish (push) Has been cancelled
CI / integration test | uv_build (push) Has been cancelled
CI / check cache | ubuntu (push) Has been cancelled
CI / check cache | macos aarch64 (push) Has been cancelled
CI / check system | python on debian (push) Has been cancelled
CI / check system | python on fedora (push) Has been cancelled
CI / check system | python on ubuntu (push) Has been cancelled
CI / check system | python on opensuse (push) Has been cancelled
CI / check system | python on rocky linux 8 (push) Has been cancelled
CI / check system | python on rocky linux 9 (push) Has been cancelled
CI / check system | python on macos aarch64 (push) Has been cancelled
CI / check system | homebrew python on macos aarch64 (push) Has been cancelled
CI / check system | python on macos x86-64 (push) Has been cancelled
CI / check system | python3.10 on windows x86-64 (push) Has been cancelled
CI / check system | python3.10 on windows x86 (push) Has been cancelled
CI / check system | python3.13 on windows x86-64 (push) Has been cancelled
CI / check system | x86-64 python3.13 on windows aarch64 (push) Has been cancelled
CI / check system | windows registry (push) Has been cancelled
CI / check system | python3.12 via chocolatey (push) Has been cancelled
CI / check system | python3.9 via pyenv (push) Has been cancelled
CI / check system | python3.13 (push) Has been cancelled
CI / check system | conda3.11 on macos aarch64 (push) Has been cancelled
CI / check system | conda3.8 on macos aarch64 (push) Has been cancelled
CI / check system | conda3.11 on linux x86-64 (push) Has been cancelled
CI / check system | conda3.8 on linux x86-64 (push) Has been cancelled
CI / check system | conda3.11 on windows x86-64 (push) Has been cancelled
CI / check system | amazonlinux (push) Has been cancelled
CI / check system | embedded python3.10 on windows x86-64 (push) Has been cancelled
CI / benchmarks (push) Has been cancelled
From PEP 440: > The exclusive ordered comparison <V MUST NOT allow a pre-release of the specified version unless the specified version is itself a pre-release. Allowing pre-releases that are earlier than, but not equal to a specific pre-release may be accomplished by using <V.rc1 or similar. We had an additional check that would block this even if the specifier did have a pre-release. This likely didn't show up earlier because `Ranges` uses different code in the resolver. I checked these changes against `packaging` to verify their behavior: ```python print(SpecifierSet("<1").contains("1a1", prereleases=True)) # False print(SpecifierSet("<1a2").contains("1a1", prereleases=True)) # True print(SpecifierSet("<1").contains("1dev1", prereleases=True)) # False print(SpecifierSet("<1dev2").contains("1dev1", prereleases=True)) # True print(SpecifierSet("<1a2").contains("1dev1", prereleases=True)) # True ``` Closes #12834
This commit is contained in:
parent
dd788a0f47
commit
6b7f60c1ea
1 changed files with 16 additions and 17 deletions
|
@ -554,16 +554,9 @@ impl VersionSpecifier {
|
|||
other.as_ref() >= this
|
||||
}
|
||||
Operator::GreaterThan => Self::greater_than(this, &other),
|
||||
Operator::GreaterThanEqual => {
|
||||
Self::greater_than(this, &other) || other.as_ref() >= this
|
||||
}
|
||||
Operator::LessThan => {
|
||||
Self::less_than(this, &other)
|
||||
&& !(version::compare_release(&this.release(), &other.release())
|
||||
== Ordering::Equal
|
||||
&& other.any_prerelease())
|
||||
}
|
||||
Operator::LessThanEqual => Self::less_than(this, &other) || other.as_ref() <= this,
|
||||
Operator::GreaterThanEqual => other.as_ref() >= this,
|
||||
Operator::LessThan => Self::less_than(this, &other),
|
||||
Operator::LessThanEqual => other.as_ref() <= this,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -572,13 +565,13 @@ impl VersionSpecifier {
|
|||
return true;
|
||||
}
|
||||
|
||||
// This special case is here so that, unless the specifier itself
|
||||
// includes is a pre-release version, that we do not accept pre-release
|
||||
// versions for the version mentioned in the specifier (e.g. <3.1 should
|
||||
// not match 3.1.dev0, but should match 3.0.dev0).
|
||||
if !this.any_prerelease()
|
||||
&& other.is_pre()
|
||||
&& version::compare_release(&this.release(), &other.release()) == Ordering::Equal
|
||||
// The exclusive ordered comparison <V MUST NOT allow a pre-release of the specified
|
||||
// version unless the specified version is itself a pre-release. E.g., <3.1 should
|
||||
// not match 3.1.dev0, but should match both 3.0.dev0 and 3.0, while <3.1.dev1 does match
|
||||
// 3.1.dev0, 3.0.dev0 and 3.0.
|
||||
if version::compare_release(&this.release(), &other.release()) == Ordering::Equal
|
||||
&& !this.any_prerelease()
|
||||
&& other.any_prerelease()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -1172,10 +1165,15 @@ mod tests {
|
|||
("2.0.1", ">2"),
|
||||
("2.1.post1", ">2"),
|
||||
("2.1+local.version", ">2"),
|
||||
("2.post2", ">2.post1"),
|
||||
// Test the less than operation
|
||||
("1", "<2"),
|
||||
("2.0", "<2.1"),
|
||||
("2.0.dev0", "<2.1"),
|
||||
// https://github.com/astral-sh/uv/issues/12834
|
||||
("0.1a1", "<0.1a2"),
|
||||
("0.1dev1", "<0.1dev2"),
|
||||
("0.1dev1", "<0.1a1"),
|
||||
// Test the compatibility operation
|
||||
("1", "~=1.0"),
|
||||
("1.0.1", "~=1.0"),
|
||||
|
@ -1271,6 +1269,7 @@ mod tests {
|
|||
("2.0c1.post1.dev1", ">2"),
|
||||
("2.0rc1", ">2"),
|
||||
("2.0", ">2"),
|
||||
("2.post2", ">2"),
|
||||
("2.0.post1", ">2"),
|
||||
("2.0.post1.dev1", ">2"),
|
||||
("2.0+local.version", ">2"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue