Allow underscores in entrypoints (#9825)

This commit is contained in:
konsti 2024-12-11 23:24:18 +01:00 committed by GitHub
parent 8110dedde7
commit c0f8e20a51
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 3 deletions

View File

@ -40,7 +40,7 @@ pub enum ValidationError {
#[error("Entrypoint groups must consist of letters and numbers separated by dots, invalid group: `{0}`")] #[error("Entrypoint groups must consist of letters and numbers separated by dots, invalid group: `{0}`")]
InvalidGroup(String), InvalidGroup(String),
#[error( #[error(
"Entrypoint names must consist of letters, numbers, dots and dashes; invalid name: `{0}`" "Entrypoint names must consist of letters, numbers, dots, underscores and dashes; invalid name: `{0}`"
)] )]
InvalidName(String), InvalidName(String),
#[error("Use `project.scripts` instead of `project.entry-points.console_scripts`")] #[error("Use `project.scripts` instead of `project.entry-points.console_scripts`")]
@ -558,7 +558,7 @@ impl PyProjectToml {
// More strict than the spec, we enforce the recommendation // More strict than the spec, we enforce the recommendation
if !name if !name
.chars() .chars()
.all(|c| c.is_alphanumeric() || c == '.' || c == '-') .all(|c| c.is_alphanumeric() || c == '.' || c == '-' || c == '_')
{ {
return Err(ValidationError::InvalidName(name.to_string())); return Err(ValidationError::InvalidName(name.to_string()));
} }
@ -1273,7 +1273,7 @@ mod tests {
"a@b" = "bar" "a@b" = "bar"
"# "#
}); });
assert_snapshot!(script_error(&contents), @"Entrypoint names must consist of letters, numbers, dots and dashes; invalid name: `a@b`"); assert_snapshot!(script_error(&contents), @"Entrypoint names must consist of letters, numbers, dots, underscores and dashes; invalid name: `a@b`");
} }
#[test] #[test]