Skip to content

Commit

Permalink
Remove deprecated tab-size option
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser committed Jun 24, 2024
1 parent 5232835 commit ce1a64e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 75 deletions.
25 changes: 25 additions & 0 deletions crates/ruff/tests/.format.rs.pending-snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{"run_id":"11268746-93ae-434e-bc47-4589354be92a","line":807,"new":{"module_name":"format","snapshot_name":"deprecated_options","metadata":{"source":"crates/ruff/tests/format.rs","assertion_line":807,"info":{"program":"ruff","args":["format","--config","/tmp/.tmpw1uE14/ruff.toml","-"],"stdin":"\nif True:\n pass\n "}},"snapshot":"success: false\nexit_code: 2\n----- stdout -----\n\n----- stderr -----\nruff failed\n Cause: Failed to parse [RUFF-TOML-PATH]\n Cause: TOML parse error at line 1, column 1\n |\n1 | \n | ^\nunknown field `tab-size`\n\n"},"old":{"module_name":"format","metadata":{},"snapshot":"success: true\nexit_code: 0\n----- stdout -----\nif True:\n pass\n\n----- stderr -----\nwarning: The `tab-size` option has been renamed to `indent-width` to emphasize that it configures the indentation used by the formatter as well as the tab width. Please update your configuration to use `indent-width = <value>` instead."}}
{"run_id":"11268746-93ae-434e-bc47-4589354be92a","line":962,"new":null,"old":null}
{"run_id":"11268746-93ae-434e-bc47-4589354be92a","line":21,"new":null,"old":null}
{"run_id":"11268746-93ae-434e-bc47-4589354be92a","line":668,"new":null,"old":null}
{"run_id":"11268746-93ae-434e-bc47-4589354be92a","line":843,"new":null,"old":null}
{"run_id":"11268746-93ae-434e-bc47-4589354be92a","line":907,"new":null,"old":null}
{"run_id":"11268746-93ae-434e-bc47-4589354be92a","line":336,"new":null,"old":null}
{"run_id":"11268746-93ae-434e-bc47-4589354be92a","line":292,"new":null,"old":null}
{"run_id":"11268746-93ae-434e-bc47-4589354be92a","line":67,"new":null,"old":null}
{"run_id":"11268746-93ae-434e-bc47-4589354be92a","line":708,"new":null,"old":null}
{"run_id":"11268746-93ae-434e-bc47-4589354be92a","line":100,"new":null,"old":null}
{"run_id":"11268746-93ae-434e-bc47-4589354be92a","line":760,"new":null,"old":null}
{"run_id":"11268746-93ae-434e-bc47-4589354be92a","line":1942,"new":null,"old":null}
{"run_id":"11268746-93ae-434e-bc47-4589354be92a","line":84,"new":null,"old":null}
{"run_id":"11268746-93ae-434e-bc47-4589354be92a","line":486,"new":null,"old":null}
{"run_id":"11268746-93ae-434e-bc47-4589354be92a","line":1748,"new":null,"old":null}
{"run_id":"11268746-93ae-434e-bc47-4589354be92a","line":634,"new":null,"old":null}
{"run_id":"11268746-93ae-434e-bc47-4589354be92a","line":1767,"new":null,"old":null}
{"run_id":"11268746-93ae-434e-bc47-4589354be92a","line":1834,"new":null,"old":null}
{"run_id":"11268746-93ae-434e-bc47-4589354be92a","line":546,"new":null,"old":null}
{"run_id":"11268746-93ae-434e-bc47-4589354be92a","line":1852,"new":null,"old":null}
{"run_id":"11268746-93ae-434e-bc47-4589354be92a","line":2035,"new":null,"old":null}
{"run_id":"11268746-93ae-434e-bc47-4589354be92a","line":424,"new":null,"old":null}
{"run_id":"11268746-93ae-434e-bc47-4589354be92a","line":559,"new":null,"old":null}
{"run_id":"11268746-93ae-434e-bc47-4589354be92a","line":571,"new":null,"old":null}
35 changes: 0 additions & 35 deletions crates/ruff/tests/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -790,41 +790,6 @@ if condition:
Ok(())
}

#[test]
fn deprecated_options() -> Result<()> {
let tempdir = TempDir::new()?;
let ruff_toml = tempdir.path().join("ruff.toml");
fs::write(
&ruff_toml,
r"
tab-size = 2
",
)?;

insta::with_settings!({filters => vec![
(&*regex::escape(ruff_toml.to_str().unwrap()), "[RUFF-TOML-PATH]"),
]}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.args(["format", "--config"])
.arg(&ruff_toml)
.arg("-")
.pass_stdin(r"
if True:
pass
"), @r###"
success: true
exit_code: 0
----- stdout -----
if True:
pass
----- stderr -----
warning: The `tab-size` option has been renamed to `indent-width` to emphasize that it configures the indentation used by the formatter as well as the tab width. Please update your configuration to use `indent-width = <value>` instead.
"###);
});
Ok(())
}

/// Since 0.1.0 the legacy format option is no longer supported
#[test]
fn legacy_format_option() -> Result<()> {
Expand Down
11 changes: 1 addition & 10 deletions crates/ruff_workspace/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,15 +420,6 @@ impl Configuration {
}
};

#[allow(deprecated)]
let indent_width = {
if options.tab_size.is_some() {
warn_user_once!("The `tab-size` option has been renamed to `indent-width` to emphasize that it configures the indentation used by the formatter as well as the tab width. Please update your configuration to use `indent-width = <value>` instead.");
}

options.indent_width.or(options.tab_size)
};

#[allow(deprecated)]
let output_format = {
if options.show_source.is_some() {
Expand Down Expand Up @@ -522,7 +513,7 @@ impl Configuration {
output_format,
force_exclude: options.force_exclude,
line_length: options.line_length,
indent_width,
indent_width: options.indent_width,
namespace_packages: options
.namespace_packages
.map(|namespace_package| resolve_src(&namespace_package, project_root))
Expand Down
18 changes: 0 additions & 18 deletions crates/ruff_workspace/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,24 +412,6 @@ pub struct Options {
)]
pub indent_width: Option<IndentWidth>,

/// The number of spaces a tab is equal to when enforcing long-line violations (like `E501`)
/// or formatting code with the formatter.
///
/// This option changes the number of spaces inserted by the formatter when
/// using soft-tabs (`indent-style = space`).
#[option(
default = "4",
value_type = "int",
example = r#"
tab-size = 2
"#
)]
#[deprecated(
since = "0.1.2",
note = "The `tab-size` option has been renamed to `indent-width` to emphasize that it configures the indentation used by the formatter as well as the tab width. Please update your configuration to use `indent-width = <value>` instead."
)]
pub tab_size: Option<IndentWidth>,

#[option_group]
pub lint: Option<LintOptions>,

Expand Down
12 changes: 0 additions & 12 deletions ruff.schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ce1a64e

Please sign in to comment.