-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
This "issue" might be the intended behavior of
uv, but I believe it should be changed.
Currently, when adding a dependency without an explicit version constraint e.g. uv add numpy, uv adds a numpy>=2.1.0 to the pyproject.toml in order to track this requirement.
Most semver upgrades are minors and patches, so this is usually fine, but >= can be problematic when said package introduces a new major version (e.g. 3.0.0).
The default behavior of Poetry, for example, is to use the caret, where ^2.1.0 is equivalent to >=2.1.0 <3.0.0, thus protecting the project from an unintended breaking upgrade.
The uv's specifier >= however, will upgrade to the most recent major by default. PEP 440 introduced the ~= "compatible release clause" / tilde, which - IMO - makes more sense to serve as the default version constraint:
~= 2.1.0
# equals to
>= 2.1.0, == 2.1.*
Note this behavior is different from Poetry's caret notation, so, unless specified, the patch version could be safely omitted by default to allow minor upgrades, while still preventing major ones:
~= 2.1
# equals to
>= 2.1, == 2.*
This is a default behavior I'd like to see from uv to ease future project upgrades.