Stylize Requires-Python consistently (#5304)

This commit is contained in:
Zanie Blue 2024-07-23 14:05:21 -04:00 committed by GitHub
parent 07d038b90c
commit 3e067766de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 17 additions and 17 deletions

View file

@ -173,7 +173,7 @@ impl SimpleHtml {
let filename = urlencoding::decode(filename)
.map_err(|_| Error::UnsupportedFilename(filename.to_string()))?;
// Extract the `requires-python` field, which should be set on the
// Extract the `requires-python` value, which should be set on the
// `data-requires-python` attribute.
let requires_python = if let Some(requires_python) =
link.attributes().get("data-requires-python").flatten()

View file

@ -829,7 +829,7 @@ impl std::fmt::Display for PubGrubHint {
} => {
write!(
f,
"{}{} The `Requires-Python` requirement ({}) includes Python versions that are not supported by your dependencies (e.g., {} only supports {}). Consider using a more restrictive `Requires-Python` requirement (like {}).",
"{}{} The `requires-python` value ({}) includes Python versions that are not supported by your dependencies (e.g., {} only supports {}). Consider using a more restrictive `requires-python` value (like {}).",
"hint".bold().cyan(),
":".bold(),
requires_python.bold(),

View file

@ -29,7 +29,7 @@ pub struct RequiresPython {
/// The supported Python versions as provides by the user, usually through the `requires-python`
/// field in `pyproject.toml`.
///
/// For a workspace, it's the union of all `requires-python` fields in the workspace. If no
/// For a workspace, it's the union of all `requires-python` values in the workspace. If no
/// bound was provided by the user, it's greater equal the current Python version.
specifiers: VersionSpecifiers,
/// The lower bound from the `specifiers` field, i.e. greater or greater equal the lowest

View file

@ -224,13 +224,13 @@ pub(super) async fn do_lock(
if requires_python.is_unbounded() {
let default =
RequiresPython::greater_than_equal_version(&interpreter.python_minor_version());
warn_user!("The workspace `requires-python` field does not contain a lower bound: `{requires_python}`. Set a lower bound to indicate the minimum compatible Python version (e.g., `{default}`).");
warn_user!("The workspace `requires-python` value does not contain a lower bound: `{requires_python}`. Set a lower bound to indicate the minimum compatible Python version (e.g., `{default}`).");
}
requires_python
} else {
let default =
RequiresPython::greater_than_equal_version(&interpreter.python_minor_version());
warn_user!("No `requires-python` field found in the workspace. Defaulting to `{default}`.");
warn_user!("No `requires-python` value found in the workspace. Defaulting to `{default}`.");
default
};

View file

@ -274,7 +274,7 @@ fn assert_pin_compatible_with_project(pin: &Pin, virtual_project: &VirtualProjec
};
Err(anyhow::anyhow!(
"The {given} Python version `{}`{resolved} is incompatible with the {} `Requires-Python` requirement of `{}`.",
"The {given} Python version `{}`{resolved} is incompatible with the {} `requires-python` value of `{}`.",
pin.request.to_canonical_string(),
project_type,
requires_python

View file

@ -111,7 +111,7 @@ fn init_no_readme() -> Result<()> {
}
#[test]
fn current_dir() -> Result<()> {
fn init_current_dir() -> Result<()> {
let context = TestContext::new("3.12");
let dir = context.temp_dir.join("foo");

View file

@ -2295,7 +2295,7 @@ fn lock_requires_python() -> Result<()> {
And because project==0.1.0 depends on pygls>=1.1.0, we can conclude that project==0.1.0 cannot be used.
And because only project==0.1.0 is available and you require project, we can conclude that the requirements are unsatisfiable.
hint: The `Requires-Python` requirement (>=3.7) includes Python versions that are not supported by your dependencies (e.g., pygls>=1.1.0,<=1.2.1 only supports >=3.7.9, <4). Consider using a more restrictive `Requires-Python` requirement (like >=3.7.9, <4).
hint: The `requires-python` value (>=3.7) includes Python versions that are not supported by your dependencies (e.g., pygls>=1.1.0,<=1.2.1 only supports >=3.7.9, <4). Consider using a more restrictive `requires-python` value (like >=3.7.9, <4).
"###);
}
@ -3119,7 +3119,7 @@ fn lock_requires_python_unbounded() -> Result<()> {
----- stderr -----
warning: `uv lock` is experimental and may change without warning
warning: The workspace `requires-python` field does not contain a lower bound: `<=3.12`. Set a lower bound to indicate the minimum compatible Python version (e.g., `>=3.11`).
warning: The workspace `requires-python` value does not contain a lower bound: `<=3.12`. Set a lower bound to indicate the minimum compatible Python version (e.g., `>=3.11`).
Resolved 2 packages in [TIME]
"###);

View file

@ -250,7 +250,7 @@ fn python_pin_compatible_with_requires_python() -> anyhow::Result<()> {
----- stdout -----
----- stderr -----
error: The requested Python version `3.10` is incompatible with the project `Requires-Python` requirement of `>=3.11`.
error: The requested Python version `3.10` is incompatible with the project `requires-python` value of `>=3.11`.
"###);
// Request a implementation version that is incompatible
@ -260,7 +260,7 @@ fn python_pin_compatible_with_requires_python() -> anyhow::Result<()> {
----- stdout -----
----- stderr -----
error: The requested Python version `cpython@3.10` is incompatible with the project `Requires-Python` requirement of `>=3.11`.
error: The requested Python version `cpython@3.10` is incompatible with the project `requires-python` value of `>=3.11`.
"###);
// Request a complex version range that resolves to an incompatible version
@ -271,7 +271,7 @@ fn python_pin_compatible_with_requires_python() -> anyhow::Result<()> {
Pinned `.python-version` to `>3.8, <3.11`
----- stderr -----
warning: The requested Python version `>3.8, <3.11` resolves to `3.10.[X]` which is incompatible with the project `Requires-Python` requirement of `>=3.11`.
warning: The requested Python version `>3.8, <3.11` resolves to `3.10.[X]` which is incompatible with the project `requires-python` value of `>=3.11`.
"###);
uv_snapshot!(context.filters(), context.python_pin().arg("3.11"), @r###"
@ -321,7 +321,7 @@ fn python_pin_compatible_with_requires_python() -> anyhow::Result<()> {
cpython@3.11
----- stderr -----
warning: The pinned Python version `cpython@3.11` is incompatible with the project `Requires-Python` requirement of `>=3.12`.
warning: The pinned Python version `cpython@3.11` is incompatible with the project `requires-python` value of `>=3.12`.
"###);
// Request a implementation that resolves to a compatible version
@ -332,7 +332,7 @@ fn python_pin_compatible_with_requires_python() -> anyhow::Result<()> {
Updated `.python-version` from `cpython@3.11` -> `cpython`
----- stderr -----
warning: The requested Python version `cpython` resolves to `3.10.[X]` which is incompatible with the project `Requires-Python` requirement of `>=3.12`.
warning: The requested Python version `cpython` resolves to `3.10.[X]` which is incompatible with the project `requires-python` value of `>=3.12`.
"###);
uv_snapshot!(context.filters(), context.python_pin(), @r###"
@ -342,7 +342,7 @@ fn python_pin_compatible_with_requires_python() -> anyhow::Result<()> {
cpython
----- stderr -----
warning: The pinned Python version `cpython` resolves to `3.10.[X]` which is incompatible with the project `Requires-Python` requirement of `>=3.12`.
warning: The pinned Python version `cpython` resolves to `3.10.[X]` which is incompatible with the project `requires-python` value of `>=3.12`.
"###);
// Request a complex version range that resolves to a compatible version
@ -353,7 +353,7 @@ fn python_pin_compatible_with_requires_python() -> anyhow::Result<()> {
Updated `.python-version` from `cpython` -> `>3.8, <3.12`
----- stderr -----
warning: The requested Python version `>3.8, <3.12` resolves to `3.10.[X]` which is incompatible with the project `Requires-Python` requirement of `>=3.12`.
warning: The requested Python version `>3.8, <3.12` resolves to `3.10.[X]` which is incompatible with the project `requires-python` value of `>=3.12`.
"###);
uv_snapshot!(context.filters(), context.python_pin(), @r###"
@ -363,7 +363,7 @@ fn python_pin_compatible_with_requires_python() -> anyhow::Result<()> {
>3.8, <3.12
----- stderr -----
warning: The pinned Python version `>3.8, <3.12` resolves to `3.10.[X]` which is incompatible with the project `Requires-Python` requirement of `>=3.12`.
warning: The pinned Python version `>3.8, <3.12` resolves to `3.10.[X]` which is incompatible with the project `requires-python` value of `>=3.12`.
"###);
Ok(())