mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-01 04:17:37 +00:00
Propagate URL errors in verbatim parsing (#3720)
## Summary Closes https://github.com/astral-sh/uv/issues/3715. ## Test Plan ``` ❯ echo "/../test" | cargo run pip compile - error: Couldn't parse requirement in `-` at position 0 Caused by: path could not be normalized: /../test /../test ^^^^^^^^ ❯ echo "-e /../test" | cargo run pip compile - error: Invalid URL in `-`: `/../test` Caused by: path could not be normalized: /../test Caused by: cannot normalize a relative path beyond the base directory ```
This commit is contained in:
parent
19df1a4372
commit
558f628ef1
9 changed files with 97 additions and 40 deletions
|
|
@ -59,6 +59,8 @@ pub enum LoweringError {
|
|||
InvalidEntry,
|
||||
#[error(transparent)]
|
||||
InvalidUrl(#[from] url::ParseError),
|
||||
#[error(transparent)]
|
||||
InvalidVerbatimUrl(#[from] pep508_rs::VerbatimUrlError),
|
||||
#[error("Can't combine URLs from both `project.dependencies` and `tool.uv.sources`")]
|
||||
ConflictingUrls,
|
||||
#[error("Could not normalize path: `{0}`")]
|
||||
|
|
@ -551,7 +553,7 @@ fn path_source(
|
|||
project_dir: &Path,
|
||||
editable: bool,
|
||||
) -> Result<RequirementSource, LoweringError> {
|
||||
let url = VerbatimUrl::parse_path(&path, project_dir).with_given(path.clone());
|
||||
let url = VerbatimUrl::parse_path(&path, project_dir)?.with_given(path.clone());
|
||||
let path_buf = PathBuf::from(&path);
|
||||
let path_buf = path_buf
|
||||
.absolutize_from(project_dir)
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ impl RequirementsSpecification {
|
|||
project: None,
|
||||
requirements: vec![UnresolvedRequirementSpecification {
|
||||
requirement: UnresolvedRequirement::Unnamed(UnnamedRequirement {
|
||||
url: VerbatimUrl::from_path(path),
|
||||
url: VerbatimUrl::from_path(path)?,
|
||||
extras: vec![],
|
||||
marker: None,
|
||||
origin: None,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue