mirror of https://github.com/astral-sh/uv
Include cycle error message in `uv pip` CLI (#15453)
## Summary The use of `format!` was dropping the error chain. Closes https://github.com/astral-sh/uv/issues/15397.
This commit is contained in:
parent
088c908cda
commit
93630a8f79
|
|
@ -215,11 +215,10 @@ pub(crate) async fn resolve<InstalledPackages: InstalledPackagesProvider>(
|
||||||
build_dispatch.workspace_cache(),
|
build_dispatch.workspace_cache(),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.with_context(|| {
|
||||||
anyhow!(
|
format!(
|
||||||
"Failed to read dependency groups from: {}\n{}",
|
"Failed to read dependency groups from: {}",
|
||||||
pyproject_path.display(),
|
pyproject_path.display()
|
||||||
e
|
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9719,6 +9719,74 @@ fn dependency_group() -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn recursive_dependency_group() -> Result<()> {
|
||||||
|
let context = TestContext::new("3.12");
|
||||||
|
|
||||||
|
// Test a self-referencing group.
|
||||||
|
let pyproject_toml = context.temp_dir.child("pyproject.toml");
|
||||||
|
pyproject_toml.write_str(
|
||||||
|
r#"
|
||||||
|
[project]
|
||||||
|
name = "myproject"
|
||||||
|
version = "0.1.0"
|
||||||
|
requires-python = ">=3.12"
|
||||||
|
|
||||||
|
[dependency-groups]
|
||||||
|
test = [
|
||||||
|
{ include-group = "test" },
|
||||||
|
"requests"
|
||||||
|
]
|
||||||
|
"#,
|
||||||
|
)?;
|
||||||
|
|
||||||
|
uv_snapshot!(context.filters(), context.pip_install()
|
||||||
|
.arg("--group").arg("test"), @r"
|
||||||
|
success: false
|
||||||
|
exit_code: 2
|
||||||
|
----- stdout -----
|
||||||
|
|
||||||
|
----- stderr -----
|
||||||
|
error: Failed to read dependency groups from: [TEMP_DIR]/pyproject.toml
|
||||||
|
Caused by: Project `myproject` has malformed dependency groups
|
||||||
|
Caused by: Detected a cycle in `dependency-groups`: `test` -> `test`
|
||||||
|
");
|
||||||
|
|
||||||
|
// Test mutually recursive groups.
|
||||||
|
pyproject_toml.write_str(
|
||||||
|
r#"
|
||||||
|
[project]
|
||||||
|
name = "myproject"
|
||||||
|
version = "0.1.0"
|
||||||
|
requires-python = ">=3.12"
|
||||||
|
|
||||||
|
[dependency-groups]
|
||||||
|
test = [
|
||||||
|
{ include-group = "dev" },
|
||||||
|
"requests"
|
||||||
|
]
|
||||||
|
dev = [
|
||||||
|
{ include-group = "test" },
|
||||||
|
"pytest"
|
||||||
|
]
|
||||||
|
"#,
|
||||||
|
)?;
|
||||||
|
|
||||||
|
uv_snapshot!(context.filters(), context.pip_install()
|
||||||
|
.arg("--group").arg("test"), @r"
|
||||||
|
success: false
|
||||||
|
exit_code: 2
|
||||||
|
----- stdout -----
|
||||||
|
|
||||||
|
----- stderr -----
|
||||||
|
error: Failed to read dependency groups from: [TEMP_DIR]/pyproject.toml
|
||||||
|
Caused by: Project `myproject` has malformed dependency groups
|
||||||
|
Caused by: Detected a cycle in `dependency-groups`: `dev` -> `test` -> `dev`
|
||||||
|
");
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn virtual_dependency_group() -> Result<()> {
|
fn virtual_dependency_group() -> Result<()> {
|
||||||
// testing basic `uv pip install --group` functionality
|
// testing basic `uv pip install --group` functionality
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue