@@ -16,8 +16,8 @@ use shellexpand::LookupError;
1616use strum:: IntoEnumIterator ;
1717
1818use ruff_cache:: cache_dir;
19- use ruff_formatter:: { IndentStyle , IndentWidth , LineWidth } ;
20- use ruff_linter:: line_width:: { LineLength , TabSize } ;
19+ use ruff_formatter:: IndentStyle ;
20+ use ruff_linter:: line_width:: { IndentWidth , LineLength } ;
2121use ruff_linter:: registry:: RuleNamespace ;
2222use ruff_linter:: registry:: { Rule , RuleSet , INCOMPATIBLE_CODES } ;
2323use ruff_linter:: rule_selector:: { PreviewOptions , Specificity } ;
@@ -132,7 +132,7 @@ pub struct Configuration {
132132
133133 // Global formatting options
134134 pub line_length : Option < LineLength > ,
135- pub tab_size : Option < TabSize > ,
135+ pub indent_width : Option < IndentWidth > ,
136136
137137 pub lint : LintConfiguration ,
138138 pub format : FormatConfiguration ,
@@ -165,14 +165,14 @@ impl Configuration {
165165 line_width : self
166166 . line_length
167167 . map_or ( format_defaults. line_width , |length| {
168- LineWidth :: from ( NonZeroU16 :: from ( length) )
168+ ruff_formatter :: LineWidth :: from ( NonZeroU16 :: from ( length) )
169169 } ) ,
170170 line_ending : format. line_ending . unwrap_or ( format_defaults. line_ending ) ,
171171 indent_style : format. indent_style . unwrap_or ( format_defaults. indent_style ) ,
172172 indent_width : self
173- . tab_size
173+ . indent_width
174174 . map_or ( format_defaults. indent_width , |tab_size| {
175- IndentWidth :: from ( NonZeroU8 :: from ( tab_size) )
175+ ruff_formatter :: IndentWidth :: from ( NonZeroU8 :: from ( tab_size) )
176176 } ) ,
177177 quote_style : format. quote_style . unwrap_or ( format_defaults. quote_style ) ,
178178 magic_trailing_comma : format
@@ -226,7 +226,7 @@ impl Configuration {
226226 external : FxHashSet :: from_iter ( lint. external . unwrap_or_default ( ) ) ,
227227 ignore_init_module_imports : lint. ignore_init_module_imports . unwrap_or_default ( ) ,
228228 line_length : self . line_length . unwrap_or_default ( ) ,
229- tab_size : self . tab_size . unwrap_or_default ( ) ,
229+ tab_size : self . indent_width . unwrap_or_default ( ) ,
230230 namespace_packages : self . namespace_packages . unwrap_or_default ( ) ,
231231 per_file_ignores : resolve_per_file_ignores (
232232 lint. per_file_ignores
@@ -383,6 +383,15 @@ impl Configuration {
383383 }
384384 } ;
385385
386+ #[ allow( deprecated) ]
387+ let indent_width = {
388+ if options. tab_size . is_some ( ) {
389+ 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." ) ;
390+ }
391+
392+ options. indent_width . or ( options. tab_size )
393+ } ;
394+
386395 Ok ( Self {
387396 builtins : options. builtins ,
388397 cache_dir : options
@@ -450,7 +459,7 @@ impl Configuration {
450459 output_format : options. output_format ,
451460 force_exclude : options. force_exclude ,
452461 line_length : options. line_length ,
453- tab_size : options . tab_size ,
462+ indent_width ,
454463 namespace_packages : options
455464 . namespace_packages
456465 . map ( |namespace_package| resolve_src ( & namespace_package, project_root) )
@@ -498,7 +507,7 @@ impl Configuration {
498507 output_format : self . output_format . or ( config. output_format ) ,
499508 force_exclude : self . force_exclude . or ( config. force_exclude ) ,
500509 line_length : self . line_length . or ( config. line_length ) ,
501- tab_size : self . tab_size . or ( config. tab_size ) ,
510+ indent_width : self . indent_width . or ( config. indent_width ) ,
502511 namespace_packages : self . namespace_packages . or ( config. namespace_packages ) ,
503512 required_version : self . required_version . or ( config. required_version ) ,
504513 respect_gitignore : self . respect_gitignore . or ( config. respect_gitignore ) ,
0 commit comments