From 100dbe475cfb00a724a376c9b5034e37627e80c1 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Tue, 30 Apr 2024 12:20:14 -0500 Subject: [PATCH] Quote version parse errors consistently (#3325) --- crates/pep440-rs/src/version.rs | 2 +- crates/pep508-rs/src/lib.rs | 9 +++++---- crates/uv/tests/pip_compile.rs | 2 +- crates/uv/tests/pip_uninstall.rs | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/crates/pep440-rs/src/version.rs b/crates/pep440-rs/src/version.rs index 310c749ed..e2dc01090 100644 --- a/crates/pep440-rs/src/version.rs +++ b/crates/pep440-rs/src/version.rs @@ -2141,7 +2141,7 @@ impl std::fmt::Display for VersionParseError { } => { write!( f, - "after parsing {version}, found {remaining:?} after it, \ + "after parsing '{version}', found '{remaining}', \ which is not part of a valid version", ) } diff --git a/crates/pep508-rs/src/lib.rs b/crates/pep508-rs/src/lib.rs index 5603ebd2a..0d35bac71 100644 --- a/crates/pep508-rs/src/lib.rs +++ b/crates/pep508-rs/src/lib.rs @@ -1997,10 +1997,11 @@ mod tests { fn error_invalid_prerelease() { assert_snapshot!( parse_pepe508_err("name==1.0.org1"), - @" - after parsing 1.0, found \".org1\" after it, which is not part of a valid version - name==1.0.org1 - ^^^^^^^^^^" + @r###" + after parsing '1.0', found '.org1', which is not part of a valid version + name==1.0.org1 + ^^^^^^^^^^ + "### ); } diff --git a/crates/uv/tests/pip_compile.rs b/crates/uv/tests/pip_compile.rs index b7589c845..4742f359c 100644 --- a/crates/uv/tests/pip_compile.rs +++ b/crates/uv/tests/pip_compile.rs @@ -984,7 +984,7 @@ fn compile_python_invalid_version() -> Result<()> { ----- stdout ----- ----- stderr ----- - error: invalid value '3.7.x' for '--python-version ': after parsing 3.7, found ".x" after it, which is not part of a valid version + error: invalid value '3.7.x' for '--python-version ': after parsing '3.7', found '.x', which is not part of a valid version For more information, try '--help'. "### diff --git a/crates/uv/tests/pip_uninstall.rs b/crates/uv/tests/pip_uninstall.rs index b6808afb9..99e4ab444 100644 --- a/crates/uv/tests/pip_uninstall.rs +++ b/crates/uv/tests/pip_uninstall.rs @@ -92,7 +92,7 @@ fn invalid_requirement() -> Result<()> { ----- stderr ----- error: Failed to parse `flask==1.0.x` - Caused by: after parsing 1.0, found ".x" after it, which is not part of a valid version + Caused by: after parsing '1.0', found '.x', which is not part of a valid version flask==1.0.x ^^^^^^^ "###); @@ -141,7 +141,7 @@ fn invalid_requirements_txt_requirement() -> Result<()> { ----- stderr ----- error: Couldn't parse requirement in `requirements.txt` at position 0 - Caused by: after parsing 1.0, found ".x" after it, which is not part of a valid version + Caused by: after parsing '1.0', found '.x', which is not part of a valid version flask==1.0.x ^^^^^^^ "###);