Upgrade to toml v0.6.0 (#2116)

Closes #1894.
This commit is contained in:
Charlie Marsh 2023-01-23 19:22:42 -05:00 committed by GitHub
parent d65ce6308b
commit 549a5d44bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 48 additions and 27 deletions

43
Cargo.lock generated
View File

@ -733,7 +733,7 @@ dependencies = [
"serde_json",
"strum",
"strum_macros",
"toml_edit",
"toml 0.6.0",
]
[[package]]
@ -1633,7 +1633,7 @@ checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9"
dependencies = [
"once_cell",
"thiserror",
"toml",
"toml 0.5.11",
]
[[package]]
@ -1875,7 +1875,7 @@ dependencies = [
"textwrap",
"thiserror",
"titlecase",
"toml_edit",
"toml 0.6.0",
"wasm-bindgen",
"wasm-bindgen-test",
]
@ -2200,6 +2200,15 @@ dependencies = [
"serde",
]
[[package]]
name = "serde_spanned"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c68e921cef53841b8925c2abadd27c9b891d9613bdc43d6b823062866df38e8"
dependencies = [
"serde",
]
[[package]]
name = "shellexpand"
version = "3.0.0"
@ -2480,32 +2489,44 @@ dependencies = [
[[package]]
name = "toml"
version = "0.5.10"
version = "0.5.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1333c76748e868a4d9d1017b5ab53171dfd095f70c712fdb4653a406547f598f"
checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234"
dependencies = [
"serde",
]
[[package]]
name = "toml_datetime"
version = "0.5.0"
name = "toml"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "808b51e57d0ef8f71115d8f3a01e7d3750d01c79cac4b3eda910f4389fdf92fd"
checksum = "4fb9d890e4dc9298b70f740f615f2e05b9db37dce531f6b24fb77ac993f9f217"
dependencies = [
"serde",
"serde_spanned",
"toml_datetime",
"toml_edit",
]
[[package]]
name = "toml_datetime"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4553f467ac8e3d374bc9a177a26801e5d0f9b211aa1673fb137a403afd1c9cf5"
dependencies = [
"serde",
]
[[package]]
name = "toml_edit"
version = "0.17.1"
version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a34cc558345efd7e88b9eda9626df2138b80bb46a7606f695e751c892bc7dac6"
checksum = "729bfd096e40da9c001f778f5cdecbd2957929a24e10e5883d9392220a751581"
dependencies = [
"indexmap",
"itertools",
"nom8",
"serde",
"serde_spanned",
"toml_datetime",
]

View File

@ -61,7 +61,7 @@ strum_macros = { version = "0.24.3" }
textwrap = { version = "0.16.0" }
thiserror = { version = "1.0" }
titlecase = { version = "2.2.1" }
toml_edit = { version = "0.17.1", features = ["easy"] }
toml = { version = "0.6.0", features= ["parse"] }
# https://docs.rs/getrandom/0.2.7/getrandom/#webassembly-support
# For (future) wasm-pack support

View File

@ -16,7 +16,7 @@ serde = { version = "1.0.147", features = ["derive"] }
serde_json = { version = "1.0.87" }
strum = { version = "0.24.1", features = ["strum_macros"] }
strum_macros = { version = "0.24.3" }
toml_edit = { version = "0.17.1", features = ["easy"] }
toml = { version = "0.6.0", features = ["parse"] }
[dev-dependencies]

View File

@ -60,7 +60,7 @@ fn main() -> Result<()> {
// Create Ruff's pyproject.toml section.
let pyproject = flake8_to_ruff::convert(&config, &external_config, cli.plugin)?;
println!("{}", toml_edit::easy::to_string_pretty(&pyproject)?);
println!("{}", toml::to_string_pretty(&pyproject)?);
Ok(())
}

View File

@ -19,6 +19,6 @@ pub struct Pyproject {
pub fn parse<P: AsRef<Path>>(path: P) -> Result<Pyproject> {
let contents = std::fs::read_to_string(path)?;
let pyproject = toml_edit::easy::from_str::<Pyproject>(&contents)?;
let pyproject = toml::from_str::<Pyproject>(&contents)?;
Ok(pyproject)
}

View File

@ -31,13 +31,13 @@ impl Pyproject {
/// Parse a `ruff.toml` file.
fn parse_ruff_toml<P: AsRef<Path>>(path: P) -> Result<Options> {
let contents = fs::read_file(path)?;
toml_edit::easy::from_str(&contents).map_err(Into::into)
toml::from_str(&contents).map_err(Into::into)
}
/// Parse a `pyproject.toml` file.
fn parse_pyproject_toml<P: AsRef<Path>>(path: P) -> Result<Pyproject> {
let contents = fs::read_file(path)?;
toml_edit::easy::from_str(&contents).map_err(Into::into)
toml::from_str(&contents).map_err(Into::into)
}
/// Return `true` if a `pyproject.toml` contains a `[tool.ruff]` section.
@ -144,17 +144,17 @@ mod tests {
#[test]
fn deserialize() -> Result<()> {
let pyproject: Pyproject = toml_edit::easy::from_str(r#""#)?;
let pyproject: Pyproject = toml::from_str(r#""#)?;
assert_eq!(pyproject.tool, None);
let pyproject: Pyproject = toml_edit::easy::from_str(
let pyproject: Pyproject = toml::from_str(
r#"
[tool.black]
"#,
)?;
assert_eq!(pyproject.tool, Some(Tools { ruff: None }));
let pyproject: Pyproject = toml_edit::easy::from_str(
let pyproject: Pyproject = toml::from_str(
r#"
[tool.black]
[tool.ruff]
@ -215,7 +215,7 @@ mod tests {
})
);
let pyproject: Pyproject = toml_edit::easy::from_str(
let pyproject: Pyproject = toml::from_str(
r#"
[tool.black]
[tool.ruff]
@ -277,7 +277,7 @@ line-length = 79
})
);
let pyproject: Pyproject = toml_edit::easy::from_str(
let pyproject: Pyproject = toml::from_str(
r#"
[tool.black]
[tool.ruff]
@ -339,7 +339,7 @@ exclude = ["foo.py"]
})
);
let pyproject: Pyproject = toml_edit::easy::from_str(
let pyproject: Pyproject = toml::from_str(
r#"
[tool.black]
[tool.ruff]
@ -401,7 +401,7 @@ select = ["E501"]
})
);
let pyproject: Pyproject = toml_edit::easy::from_str(
let pyproject: Pyproject = toml::from_str(
r#"
[tool.black]
[tool.ruff]
@ -464,7 +464,7 @@ ignore = ["E501"]
})
);
assert!(toml_edit::easy::from_str::<Pyproject>(
assert!(toml::from_str::<Pyproject>(
r#"
[tool.black]
[tool.ruff]
@ -473,7 +473,7 @@ line_length = 79
)
.is_err());
assert!(toml_edit::easy::from_str::<Pyproject>(
assert!(toml::from_str::<Pyproject>(
r#"
[tool.black]
[tool.ruff]
@ -482,7 +482,7 @@ select = ["E123"]
)
.is_err());
assert!(toml_edit::easy::from_str::<Pyproject>(
assert!(toml::from_str::<Pyproject>(
r#"
[tool.black]
[tool.ruff]