Skip to content

Commit

Permalink
Error when using the tab-size option (#12006)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser authored Jun 25, 2024
1 parent 3ad1c6c commit a239033
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
9 changes: 4 additions & 5 deletions crates/ruff/tests/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -812,14 +812,13 @@ tab-size = 2
if True:
pass
"), @r###"
success: true
exit_code: 0
success: false
exit_code: 2
----- 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.
ruff failed
Cause: 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 `[RUFF-TOML-PATH]` to use `indent-width = <value>` instead.
"###);
});
Ok(())
Expand Down
16 changes: 8 additions & 8 deletions crates/ruff_workspace/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,13 +421,13 @@ 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)
};
if options.tab_size.is_some() {
let config_to_update = path.map_or_else(
|| String::from("your `--config` CLI arguments"),
|path| format!("`{}`", fs::relativize_path(path)),
);
return Err(anyhow!("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 {config_to_update} to use `indent-width = <value>` instead."));
}

let output_format = {
options
Expand Down Expand Up @@ -508,7 +508,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
7 changes: 0 additions & 7 deletions crates/ruff_workspace/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,6 @@ pub struct Options {
///
/// 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."
Expand Down

0 comments on commit a239033

Please sign in to comment.