diff --git a/crates/ruff/tests/.format.rs.pending-snap b/crates/ruff/tests/.format.rs.pending-snap new file mode 100644 index 00000000000000..2678e00e81b24f --- /dev/null +++ b/crates/ruff/tests/.format.rs.pending-snap @@ -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 = ` 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} diff --git a/crates/ruff/tests/format.rs b/crates/ruff/tests/format.rs index 083d26bddb5917..343dfc1d3cdab6 100644 --- a/crates/ruff/tests/format.rs +++ b/crates/ruff/tests/format.rs @@ -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 = ` instead. - "###); - }); - Ok(()) -} - /// Since 0.1.0 the legacy format option is no longer supported #[test] fn legacy_format_option() -> Result<()> { diff --git a/crates/ruff_workspace/src/configuration.rs b/crates/ruff_workspace/src/configuration.rs index 7cb2a5c5083fc5..6a344a905c87f1 100644 --- a/crates/ruff_workspace/src/configuration.rs +++ b/crates/ruff_workspace/src/configuration.rs @@ -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 = ` instead."); - } - - options.indent_width.or(options.tab_size) - }; - #[allow(deprecated)] let output_format = { if options.show_source.is_some() { @@ -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)) diff --git a/crates/ruff_workspace/src/options.rs b/crates/ruff_workspace/src/options.rs index f227d2dfdab67c..10f2d54687a97d 100644 --- a/crates/ruff_workspace/src/options.rs +++ b/crates/ruff_workspace/src/options.rs @@ -412,24 +412,6 @@ pub struct Options { )] pub indent_width: Option, - /// 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 = ` instead." - )] - pub tab_size: Option, - #[option_group] pub lint: Option, diff --git a/ruff.schema.json b/ruff.schema.json index 15779c1222558c..5cef514ef7d172 100644 --- a/ruff.schema.json +++ b/ruff.schema.json @@ -688,18 +688,6 @@ "type": "string" } }, - "tab-size": { - "description": "The number of spaces a tab is equal to when enforcing long-line violations (like `E501`) or formatting code with the formatter.\n\nThis option changes the number of spaces inserted by the formatter when using soft-tabs (`indent-style = space`).", - "deprecated": true, - "anyOf": [ - { - "$ref": "#/definitions/IndentWidth" - }, - { - "type": "null" - } - ] - }, "target-version": { "description": "The minimum Python version to target, e.g., when considering automatic code upgrades, like rewriting type annotations. Ruff will not propose changes using features that are not available in the given version.\n\nFor example, to represent supporting Python >=3.10 or ==3.10 specify `target-version = \"py310\"`.\n\nIf you're already using a `pyproject.toml` file, we recommend `project.requires-python` instead, as it's based on Python packaging standards, and will be respected by other tools. For example, Ruff treats the following as identical to `target-version = \"py38\"`:\n\n```toml [project] requires-python = \">=3.8\" ```\n\nIf both are specified, `target-version` takes precedence over `requires-python`.", "anyOf": [