Improve Ruff Formatter Interoperability (#6472)

This commit is contained in:
magic-akari 2023-08-10 20:39:53 +08:00 committed by GitHub
parent 50dab9cea6
commit dc3275fe7f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 4 deletions

View file

@ -92,7 +92,13 @@ impl FromStr for IndentStyle {
"tab" | "Tabs" => Ok(Self::Tab),
"space" | "Spaces" => Ok(Self::Space(IndentStyle::DEFAULT_SPACES)),
// TODO: replace this error with a diagnostic
_ => Err("Value not supported for IndentStyle"),
v => {
let v = v.strip_prefix("Spaces, size: ").unwrap_or(v);
u8::from_str(v)
.map(Self::Space)
.map_err(|_| "Value not supported for IndentStyle")
}
}
}
}