mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 02:48:17 +00:00
Validate package and extra name (#290)
`PackageName` and `ExtraName` can now only be constructed from valid names. They share the same rules, so i gave them the same implementation. Constructors are split between `new` (owned) and `from_str` (borrowed), with the owned version avoiding allocations. Closes #279 --------- Co-authored-by: Zanie <contact@zanie.dev>
This commit is contained in:
parent
ea28b3d0d3
commit
81f380b10e
17 changed files with 258 additions and 171 deletions
|
@ -53,7 +53,7 @@ impl PubGrubDependencies {
|
|||
.clone()
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.map(|extra| to_pubgrub(requirement, Some(ExtraName::new(extra)))),
|
||||
.map(|extra| to_pubgrub(requirement, Some(extra))),
|
||||
) {
|
||||
let (package, version) = result?;
|
||||
|
||||
|
@ -101,7 +101,7 @@ impl PubGrubDependencies {
|
|||
.clone()
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.map(|extra| to_pubgrub(constraint, Some(ExtraName::new(extra)))),
|
||||
.map(|extra| to_pubgrub(constraint, Some(extra))),
|
||||
) {
|
||||
let (package, version) = result?;
|
||||
|
||||
|
|
|
@ -518,7 +518,7 @@ impl<'a, Context: BuildContext + Sync> Resolver<'a, Context> {
|
|||
if !metadata
|
||||
.provides_extras
|
||||
.iter()
|
||||
.any(|provided_extra| ExtraName::new(provided_extra) == *extra)
|
||||
.any(|provided_extra| provided_extra == extra)
|
||||
{
|
||||
return Ok(Dependencies::Unknown);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue