Clearer error message when line-length goes beyond threshold (#21072)

Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
Shahar Naveh 2025-10-27 09:42:48 +02:00 committed by GitHub
parent fdb8ea487c
commit fa12fd0184
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 29 additions and 2 deletions

View file

@ -266,7 +266,6 @@ mod tests {
use crate::pyproject::{Pyproject, Tools, find_settings_toml, parse_pyproject_toml};
#[test]
fn deserialize() -> Result<()> {
let pyproject: Pyproject = toml::from_str(r"")?;
assert_eq!(pyproject.tool, None);
@ -456,6 +455,19 @@ other-attribute = 1
.is_err()
);
let invalid_line_length = toml::from_str::<Pyproject>(
r"
[tool.ruff]
line-length = 500
",
)
.expect_err("Deserialization should have failed for a too large line-length");
assert_eq!(
invalid_line_length.message(),
"line-length must be between 1 and 320 (got 500)"
);
Ok(())
}