Warn when patch isn't specified (#7959)

When patch version isn't specified and a matching version is referenced,
it will default patch to 0 which could be unclear/confusing. This PR
warns the user of that default.

<!--
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

<!-- What's the purpose of the change? What does it do, and why? -->

The first part of this issue
https://github.com/astral-sh/uv/issues/7426. Will tackle the second part
mentioned (`~=`) in a separate PR once I know this is the correct way to
warn users.

## Test Plan

<!-- How was it tested? -->

Unit tests were added

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
This commit is contained in:
Ian Paul 2024-10-16 11:21:26 +07:00 committed by GitHub
parent 999b3f06a4
commit e71b1d0c42
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 38 additions and 0 deletions

View file

@ -248,6 +248,18 @@ impl RequiresPython {
self.range.lower().as_ref() == Bound::Unbounded
}
/// Returns `true` if the `Requires-Python` specifier is set to an exact version
/// without specifying a patch version. (e.g. `==3.10`)
pub fn is_exact_without_patch(&self) -> bool {
match self.range.lower().as_ref() {
Bound::Included(version) => {
version.release().len() == 2
&& self.range.upper().as_ref() == Bound::Included(version)
}
_ => false,
}
}
/// Returns the [`RequiresPythonBound`] truncated to the major and minor version.
pub fn bound_major_minor(&self) -> LowerBound {
match self.range.lower().as_ref() {