mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-24 13:33:50 +00:00
Unify line size settings between ruff and the formatter (#6873)
This commit is contained in:
parent
a6aa16630d
commit
e615870659
28 changed files with 227 additions and 190 deletions
|
@ -21,6 +21,7 @@ use similar::{ChangeTag, TextDiff};
|
|||
use std::fmt::{Display, Formatter};
|
||||
use std::fs::File;
|
||||
use std::io::{BufWriter, Write};
|
||||
use std::num::NonZeroU16;
|
||||
use std::ops::{Add, AddAssign};
|
||||
use std::panic::catch_unwind;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
@ -838,7 +839,7 @@ struct PyprojectTomlTool {
|
|||
struct BlackOptions {
|
||||
// Black actually allows both snake case and kebab case
|
||||
#[serde(alias = "line-length")]
|
||||
line_length: u16,
|
||||
line_length: NonZeroU16,
|
||||
#[serde(alias = "skip-magic-trailing-comma")]
|
||||
skip_magic_trailing_comma: bool,
|
||||
#[allow(unused)]
|
||||
|
@ -849,7 +850,7 @@ struct BlackOptions {
|
|||
impl Default for BlackOptions {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
line_length: 88,
|
||||
line_length: NonZeroU16::new(88).unwrap(),
|
||||
skip_magic_trailing_comma: false,
|
||||
force_exclude: None,
|
||||
}
|
||||
|
@ -893,9 +894,7 @@ impl BlackOptions {
|
|||
|
||||
fn to_py_format_options(&self, file: &Path) -> PyFormatOptions {
|
||||
PyFormatOptions::from_extension(file)
|
||||
.with_line_width(
|
||||
LineWidth::try_from(self.line_length).expect("Invalid line length limit"),
|
||||
)
|
||||
.with_line_width(LineWidth::from(self.line_length))
|
||||
.with_magic_trailing_comma(if self.skip_magic_trailing_comma {
|
||||
MagicTrailingComma::Ignore
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue