Increase max value of line-length setting (#24962)

Co-authored-by: Erik Johnson <source@ekriirke.net>
Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
Erik Johnson
2026-05-05 16:08:51 +02:00
committed by GitHub
parent 2558b41d61
commit ea6be89b0a
4 changed files with 12 additions and 41 deletions
+5 -7
View File
@@ -13,16 +13,14 @@ use ruff_text_size::TextSize;
/// The length of a line of text that is considered too long.
///
/// The allowed range of values is 1..=320
/// The allowed range of values is 1..=65535
#[derive(Clone, Copy, Debug, Eq, PartialEq, serde::Serialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct LineLength(
#[cfg_attr(feature = "schemars", schemars(range(min = 1, max = 320)))] NonZeroU16,
);
pub struct LineLength(NonZeroU16);
impl LineLength {
/// Maximum allowed value for a valid [`LineLength`]
pub const MAX: u16 = 320;
pub const MAX: u16 = u16::MAX;
/// Return the numeric value for this [`LineLength`]
pub fn value(&self) -> u16 {
@@ -115,8 +113,8 @@ impl TryFrom<u16> for LineLength {
fn try_from(value: u16) -> Result<Self, Self::Error> {
match NonZeroU16::try_from(value) {
Ok(value) if value.get() <= Self::MAX => Ok(LineLength(value)),
Ok(_) | Err(_) => Err(LineLengthFromIntError(value)),
Ok(value) => Ok(LineLength(value)),
Err(_) => Err(LineLengthFromIntError(value)),
}
}
}
+1 -1
View File
@@ -439,7 +439,7 @@ pub struct Options {
/// The length is determined by the number of characters per line, except for lines containing East Asian characters or emojis.
/// For these lines, the [unicode width](https://unicode.org/reports/tr11/) of each character is added up to determine the length.
///
/// The value must be greater than `0` and less than or equal to `320`.
/// The value must be greater than `0`.
///
/// Note: While the formatter will attempt to format lines such that they remain
/// within the `line-length`, it isn't a hard upper bound, and formatted lines may
+3 -30
View File
@@ -473,33 +473,6 @@ 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)"
);
// Test value at u16::MAX boundary (65535) - should show range error
let invalid_line_length_65535 = toml::from_str::<Pyproject>(
r"
[tool.ruff]
line-length = 65535
",
)
.expect_err("Deserialization should have failed for line-length at u16::MAX");
assert_eq!(
invalid_line_length_65535.message(),
"line-length must be between 1 and 320 (got 65535)"
);
// Test value exceeding u16::MAX (65536) - should show clear error
let invalid_line_length_65536 = toml::from_str::<Pyproject>(
r"
@@ -511,7 +484,7 @@ line-length = 65536
assert_eq!(
invalid_line_length_65536.message(),
"line-length must be between 1 and 320 (got 65536)"
"line-length must be between 1 and 65535 (got 65536)"
);
// Test value far exceeding u16::MAX (99_999) - should show clear error
@@ -525,7 +498,7 @@ line-length = 99_999
assert_eq!(
invalid_line_length_99999.message(),
"line-length must be between 1 and 320 (got 99999)"
"line-length must be between 1 and 65535 (got 99999)"
);
// Test negative value - should show clear error
@@ -539,7 +512,7 @@ line-length = -5
assert_eq!(
invalid_line_length_negative.message(),
"line-length must be between 1 and 320 (got -5)"
"line-length must be between 1 and 65535 (got -5)"
);
Ok(())
+3 -3
View File
@@ -498,7 +498,7 @@
"deprecated": true
},
"line-length": {
"description": "The line length to use when enforcing long-lines violations (like `E501`)\nand at which `isort` and the formatter prefers to wrap lines.\n\nThe length is determined by the number of characters per line, except for lines containing East Asian characters or emojis.\nFor these lines, the [unicode width](https://unicode.org/reports/tr11/) of each character is added up to determine the length.\n\nThe value must be greater than `0` and less than or equal to `320`.\n\nNote: While the formatter will attempt to format lines such that they remain\nwithin the `line-length`, it isn't a hard upper bound, and formatted lines may\nexceed the `line-length`.\n\nSee [`pycodestyle.max-line-length`](#lint_pycodestyle_max-line-length) to configure different lengths for `E501` and the formatter.",
"description": "The line length to use when enforcing long-lines violations (like `E501`)\nand at which `isort` and the formatter prefers to wrap lines.\n\nThe length is determined by the number of characters per line, except for lines containing East Asian characters or emojis.\nFor these lines, the [unicode width](https://unicode.org/reports/tr11/) of each character is added up to determine the length.\n\nThe value must be greater than `0`.\n\nNote: While the formatter will attempt to format lines such that they remain\nwithin the `line-length`, it isn't a hard upper bound, and formatted lines may\nexceed the `line-length`.\n\nSee [`pycodestyle.max-line-length`](#lint_pycodestyle_max-line-length) to configure different lengths for `E501` and the formatter.",
"anyOf": [
{
"$ref": "#/definitions/LineLength"
@@ -2101,10 +2101,10 @@
]
},
"LineLength": {
"description": "The length of a line of text that is considered too long.\n\nThe allowed range of values is 1..=320",
"description": "The length of a line of text that is considered too long.\n\nThe allowed range of values is 1..=65535",
"type": "integer",
"format": "uint16",
"maximum": 320,
"maximum": 65535,
"minimum": 1
},
"LineWidth": {