Indent wheels like dependencies in the lockfile (#4582)

This PR contains two style changes to the lockfile:
* Always indent lists of objects, even with they are only a single
element.
* Use 4 spaces instead of tabs for indenting, to mirror what we do in
the ruff formatter.
This commit is contained in:
konsti 2024-06-27 22:26:47 +02:00 committed by GitHub
parent 4c1181b9e1
commit 80e45d3174
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 734 additions and 459 deletions

View file

@ -448,24 +448,13 @@ impl Lock {
}
if !dist.wheels.is_empty() {
let wheels = dist
.wheels
.iter()
.enumerate()
.map(|(i, wheel)| {
let mut table = wheel.to_toml()?;
if dist.wheels.len() > 1 {
// Indent each wheel on a new line.
table.decor_mut().set_prefix("\n\t");
if i == dist.wheels.len() - 1 {
table.decor_mut().set_suffix("\n");
}
}
Ok(table)
})
.collect::<anyhow::Result<Array>>()?;
let wheels = each_element_on_its_line_array(
dist.wheels
.iter()
.map(Wheel::to_toml)
.collect::<anyhow::Result<Vec<_>>>()?
.into_iter(),
);
table.insert("wheels", value(wheels));
}