From f1d80a40689e6aa8f4407a47fdfa1ab37d0c3e04 Mon Sep 17 00:00:00 2001 From: konstin Date: Tue, 20 Feb 2024 12:21:06 +0100 Subject: [PATCH 1/2] Better error message for missing space before semicolon in requirements PEP 508 requires a space between a URL and the semicolon separating it from the markers to disambiguate it from a url ending with a semicolon. This is easy to get wrong because the space is not required after a plain name of PEP 440 specifier. The new error message explicitly points out the missing space. Fixes #1637. --- crates/pep508-rs/src/lib.rs | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/crates/pep508-rs/src/lib.rs b/crates/pep508-rs/src/lib.rs index c1a8c43d2e08..1dbb72ffd8ed 100644 --- a/crates/pep508-rs/src/lib.rs +++ b/crates/pep508-rs/src/lib.rs @@ -931,12 +931,16 @@ fn parse(cursor: &mut Cursor, working_dir: Option<&Path>) -> Result { cursor.next(); Some(VersionOrUrl::Url(parse_url(cursor, working_dir)?)) } + // name_req Some('(') => parse_version_specifier_parentheses(cursor)?, + // name_req Some('<' | '=' | '>' | '~' | '!') => parse_version_specifier(cursor)?, + // No requirements / any version Some(';') | None => None, Some(other) => { // Rewind to the start of the version specifier, to see if the user added a URL without @@ -963,6 +967,8 @@ fn parse(cursor: &mut Cursor, working_dir: Option<&Path>) -> Result) -> Result Date: Tue, 20 Feb 2024 17:29:40 +0100 Subject: [PATCH 2/2] More context for error message --- crates/pep508-rs/src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/pep508-rs/src/lib.rs b/crates/pep508-rs/src/lib.rs index 1dbb72ffd8ed..e3b53747cc03 100644 --- a/crates/pep508-rs/src/lib.rs +++ b/crates/pep508-rs/src/lib.rs @@ -986,7 +986,9 @@ fn parse(cursor: &mut Cursor, working_dir: Option<&Path>) -> Result