Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 5 additions & 17 deletions crates/uv-build-backend/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::str::FromStr;

use itertools::Itertools;
use serde::Deserialize;
use tracing::{debug, trace};
use tracing::{debug, trace, warn};
use version_ranges::Ranges;
use walkdir::WalkDir;

Expand Down Expand Up @@ -54,10 +54,6 @@ pub enum ValidationError {
"Entrypoint groups must consist of letters and numbers separated by dots, invalid group: `{0}`"
)]
InvalidGroup(String),
#[error(
"Entrypoint names must consist of letters, numbers, dots, underscores and dashes; invalid name: `{0}`"
)]
InvalidName(String),
#[error("Use `project.scripts` instead of `project.entry-points.console_scripts`")]
ReservedScripts,
#[error("Use `project.gui-scripts` instead of `project.entry-points.gui_scripts`")]
Expand Down Expand Up @@ -620,12 +616,14 @@ impl PyProjectToml {

let _ = writeln!(writer, "[{group}]");
for (name, object_reference) in entries {
// More strict than the spec, we enforce the recommendation
if !name
.chars()
.all(|c| c.is_alphanumeric() || c == '.' || c == '-' || c == '_')
{
return Err(ValidationError::InvalidName(name.to_string()));
warn!(
"Entrypoint names should consist of letters, numbers, dots, underscores and \
dashes; non-compliant name: `{name}`"
);
}

// TODO(konsti): Validate that the object references are valid Python identifiers.
Expand Down Expand Up @@ -1403,16 +1401,6 @@ mod tests {
assert_snapshot!(script_error(&contents), @"Entrypoint groups must consist of letters and numbers separated by dots, invalid group: `a@b`");
}

#[test]
fn invalid_entry_point_name() {
let contents = extend_project(indoc! {r#"
[project.scripts]
"a@b" = "bar"
"#
});
assert_snapshot!(script_error(&contents), @"Entrypoint names must consist of letters, numbers, dots, underscores and dashes; invalid name: `a@b`");
}

#[test]
fn invalid_entry_point_conflict_scripts() {
let contents = extend_project(indoc! {r#"
Expand Down
Loading