diff --git a/crates/ruff/resources/test/fixtures/include-test/nested-project/pyproject.toml b/crates/ruff/resources/test/fixtures/include-test/nested-project/pyproject.toml index acbc6447e5fad9..301b2a684401c8 100644 --- a/crates/ruff/resources/test/fixtures/include-test/nested-project/pyproject.toml +++ b/crates/ruff/resources/test/fixtures/include-test/nested-project/pyproject.toml @@ -1,2 +1,2 @@ -[tool.ruff] +[tool.ruff.lint] select = [] diff --git a/crates/ruff/resources/test/fixtures/include-test/pyproject.toml b/crates/ruff/resources/test/fixtures/include-test/pyproject.toml index fadb2359fba35d..62b5d15c8460c1 100644 --- a/crates/ruff/resources/test/fixtures/include-test/pyproject.toml +++ b/crates/ruff/resources/test/fixtures/include-test/pyproject.toml @@ -1,2 +1,2 @@ [tool.ruff] -include = ["a.py", "subdirectory/c.py"] \ No newline at end of file +include = ["a.py", "subdirectory/c.py"] diff --git a/crates/ruff/src/args.rs b/crates/ruff/src/args.rs index 77399ee2db0b2a..f06bab351a2e75 100644 --- a/crates/ruff/src/args.rs +++ b/crates/ruff/src/args.rs @@ -603,7 +603,6 @@ impl ConfigArguments { .unwrap_or_else(|option| option.deref().clone()); overrides = overrides.combine(Configuration::from_options( overridden_option, - None, &path_dedot::CWD, )?); } diff --git a/crates/ruff/tests/format.rs b/crates/ruff/tests/format.rs index 083d26bddb5917..fd4b9a968442b3 100644 --- a/crates/ruff/tests/format.rs +++ b/crates/ruff/tests/format.rs @@ -657,6 +657,7 @@ fn exclude_stdin() -> Result<()> { fs::write( &ruff_toml, r#" +[lint] extend-select = ["B", "Q"] ignore = ["Q000", "Q001", "Q002", "Q003"] @@ -683,9 +684,6 @@ if __name__ == '__main__': say_hy("dear Ruff contributor") ----- stderr ----- - warning: The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in `ruff.toml`: - - 'extend-select' -> 'lint.extend-select' - - 'ignore' -> 'lint.ignore' "###); Ok(()) } @@ -697,6 +695,7 @@ fn force_exclude_stdin() -> Result<()> { fs::write( &ruff_toml, r#" +[lint] extend-select = ["B", "Q"] ignore = ["Q000", "Q001", "Q002", "Q003"] @@ -724,9 +723,6 @@ if __name__ == '__main__': say_hy("dear Ruff contributor") ----- stderr ----- - warning: The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in `ruff.toml`: - - 'extend-select' -> 'lint.extend-select' - - 'ignore' -> 'lint.ignore' "###); Ok(()) } diff --git a/crates/ruff/tests/lint.rs b/crates/ruff/tests/lint.rs index f6c4072d1c617d..0ecee3d687626c 100644 --- a/crates/ruff/tests/lint.rs +++ b/crates/ruff/tests/lint.rs @@ -18,49 +18,6 @@ fn tempdir_filter(tempdir: &TempDir) -> String { format!(r"{}\\?/?", escape(tempdir.path().to_str().unwrap())) } -#[test] -fn top_level_options() -> Result<()> { - let tempdir = TempDir::new()?; - let ruff_toml = tempdir.path().join("ruff.toml"); - fs::write( - &ruff_toml, - r#" -extend-select = ["B", "Q"] - -[flake8-quotes] -inline-quotes = "single" -"#, - )?; - - insta::with_settings!({ - filters => vec![(tempdir_filter(&tempdir).as_str(), "[TMP]/")] - }, { - assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) - .args(STDIN_BASE_OPTIONS) - .arg("--config") - .arg(&ruff_toml) - .args(["--stdin-filename", "test.py"]) - .arg("-") - .pass_stdin(r#"a = "abcba".strip("aba")"#), @r###" - success: false - exit_code: 1 - ----- stdout ----- - test.py:1:5: Q000 [*] Double quotes found but single quotes preferred - test.py:1:5: B005 Using `.strip()` with multi-character strings is misleading - test.py:1:19: Q000 [*] Double quotes found but single quotes preferred - Found 3 errors. - [*] 2 fixable with the `--fix` option. - - ----- stderr ----- - warning: The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in `[TMP]/ruff.toml`: - - 'extend-select' -> 'lint.extend-select' - - 'flake8-quotes' -> 'lint.flake8-quotes' - "###); - }); - - Ok(()) -} - #[test] fn lint_options() -> Result<()> { let tempdir = TempDir::new()?; @@ -101,94 +58,6 @@ inline-quotes = "single" Ok(()) } -/// Tests that configurations from the top-level and `lint` section are merged together. -#[test] -fn mixed_levels() -> Result<()> { - let tempdir = TempDir::new()?; - let ruff_toml = tempdir.path().join("ruff.toml"); - fs::write( - &ruff_toml, - r#" -extend-select = ["B", "Q"] - -[lint.flake8-quotes] -inline-quotes = "single" -"#, - )?; - - insta::with_settings!({ - filters => vec![(tempdir_filter(&tempdir).as_str(), "[TMP]/")] - }, { - assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) - .args(STDIN_BASE_OPTIONS) - .arg("--config") - .arg(&ruff_toml) - .arg("-") - .pass_stdin(r#"a = "abcba".strip("aba")"#), @r###" - success: false - exit_code: 1 - ----- stdout ----- - -:1:5: Q000 [*] Double quotes found but single quotes preferred - -:1:5: B005 Using `.strip()` with multi-character strings is misleading - -:1:19: Q000 [*] Double quotes found but single quotes preferred - Found 3 errors. - [*] 2 fixable with the `--fix` option. - - ----- stderr ----- - warning: The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in `[TMP]/ruff.toml`: - - 'extend-select' -> 'lint.extend-select' - "###); - }); - - Ok(()) -} - -/// Tests that options in the `lint` section have higher precedence than top-level options (because they are more specific). -#[test] -fn precedence() -> Result<()> { - let tempdir = TempDir::new()?; - let ruff_toml = tempdir.path().join("ruff.toml"); - fs::write( - &ruff_toml, - r#" -[lint] -extend-select = ["B", "Q"] - -[flake8-quotes] -inline-quotes = "double" - -[lint.flake8-quotes] -inline-quotes = "single" -"#, - )?; - - insta::with_settings!({ - filters => vec![(tempdir_filter(&tempdir).as_str(), "[TMP]/")] - }, { - assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) - .args(STDIN_BASE_OPTIONS) - .arg("--config") - .arg(&ruff_toml) - .arg("-") - .pass_stdin(r#"a = "abcba".strip("aba")"#), @r###" - success: false - exit_code: 1 - ----- stdout ----- - -:1:5: Q000 [*] Double quotes found but single quotes preferred - -:1:5: B005 Using `.strip()` with multi-character strings is misleading - -:1:19: Q000 [*] Double quotes found but single quotes preferred - Found 3 errors. - [*] 2 fixable with the `--fix` option. - - ----- stderr ----- - warning: The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in `[TMP]/ruff.toml`: - - 'flake8-quotes' -> 'lint.flake8-quotes' - "###); - }); - - Ok(()) -} - #[test] fn exclude() -> Result<()> { let tempdir = TempDir::new()?; @@ -196,11 +65,11 @@ fn exclude() -> Result<()> { fs::write( &ruff_toml, r#" -extend-select = ["B", "Q"] extend-exclude = ["out"] [lint] exclude = ["test.py", "generated.py"] +extend-select = ["B", "Q"] [lint.flake8-quotes] inline-quotes = "single" @@ -262,8 +131,6 @@ OTHER = "OTHER" [*] 3 fixable with the `--fix` option. ----- stderr ----- - warning: The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in `ruff.toml`: - - 'extend-select' -> 'lint.extend-select' "###); }); @@ -277,9 +144,9 @@ fn exclude_stdin() -> Result<()> { fs::write( &ruff_toml, r#" -extend-select = ["B", "Q"] [lint] +extend-select = ["B", "Q"] exclude = ["generated.py"] [lint.flake8-quotes] @@ -311,8 +178,6 @@ if __name__ == "__main__": [*] 2 fixable with the `--fix` option. ----- stderr ----- - warning: The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in `ruff.toml`: - - 'extend-select' -> 'lint.extend-select' "###); }); @@ -327,9 +192,11 @@ fn line_too_long_width_override() -> Result<()> { &ruff_toml, r#" line-length = 80 + +[lint] select = ["E501"] -[pycodestyle] +[lint.pycodestyle] max-line-length = 100 "#, )?; @@ -356,9 +223,6 @@ _ = "--------------------------------------------------------------------------- Found 1 error. ----- stderr ----- - warning: The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in `[TMP]/ruff.toml`: - - 'select' -> 'lint.select' - - 'pycodestyle' -> 'lint.pycodestyle' "###); }); @@ -372,6 +236,7 @@ fn per_file_ignores_stdin() -> Result<()> { fs::write( &ruff_toml, r#" +[lint] extend-select = ["B", "Q"] [lint.flake8-quotes] @@ -405,8 +270,6 @@ if __name__ == "__main__": [*] 1 fixable with the `--fix` option. ----- stderr ----- - warning: The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in `ruff.toml`: - - 'extend-select' -> 'lint.extend-select' "###); }); @@ -420,6 +283,7 @@ fn extend_per_file_ignores_stdin() -> Result<()> { fs::write( &ruff_toml, r#" +[lint] extend-select = ["B", "Q"] [lint.flake8-quotes] @@ -453,8 +317,6 @@ if __name__ == "__main__": [*] 1 fixable with the `--fix` option. ----- stderr ----- - warning: The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in `ruff.toml`: - - 'extend-select' -> 'lint.extend-select' "###); }); @@ -698,14 +560,14 @@ x = "longer_than_90_charactersssssssssssssssssssssssssssssssssssssssssssssssssss fn valid_toml_but_nonexistent_option_provided_via_config_argument() { assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) .args(STDIN_BASE_OPTIONS) - .args([".", "--config", "extend-select=['F481']"]), // No such code as F481! + .args([".", "--config", "lint.extend-select=['F481']"]), // No such code as F481! @r###" success: false exit_code: 2 ----- stdout ----- ----- stderr ----- - error: invalid value 'extend-select=['F481']' for '--config ' + error: invalid value 'lint.extend-select=['F481']' for '--config ' tip: A `--config` flag must either be a path to a `.toml` configuration file or a TOML ` = ` pair overriding a specific configuration @@ -714,6 +576,7 @@ fn valid_toml_but_nonexistent_option_provided_via_config_argument() { Could not parse the supplied argument as a `ruff.toml` configuration option: Unknown rule selector: `F481` + in `lint.extend-select` For more information, try '--help'. "###); @@ -841,25 +704,6 @@ fn complex_config_setting_overridden_via_cli() -> Result<()> { Ok(()) } -#[test] -fn deprecated_config_option_overridden_via_cli() { - assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) - .args(STDIN_BASE_OPTIONS) - .args(["--config", "select=['N801']", "-"]) - .pass_stdin("class lowercase: ..."), - @r###" - success: false - exit_code: 1 - ----- stdout ----- - -:1:7: N801 Class name `lowercase` should use CapWords convention - Found 1 error. - - ----- stderr ----- - warning: The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in your `--config` CLI arguments: - - 'select' -> 'lint.select' - "###); -} - #[test] fn extension() -> Result<()> { let tempdir = TempDir::new()?; diff --git a/crates/ruff/tests/resolve_files.rs b/crates/ruff/tests/resolve_files.rs index 4f647489552878..b9f75a8760b2af 100644 --- a/crates/ruff/tests/resolve_files.rs +++ b/crates/ruff/tests/resolve_files.rs @@ -39,8 +39,6 @@ fn check_project_include_defaults() { [BASEPATH]/include-test/subdirectory/c.py ----- stderr ----- - warning: The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in `nested-project/pyproject.toml`: - - 'select' -> 'lint.select' "###); }); } diff --git a/crates/ruff_server/src/session/index/ruff_settings.rs b/crates/ruff_server/src/session/index/ruff_settings.rs index 39b35fa97bf16d..b2145e656d5cb8 100644 --- a/crates/ruff_server/src/session/index/ruff_settings.rs +++ b/crates/ruff_server/src/session/index/ruff_settings.rs @@ -295,5 +295,5 @@ fn open_configuration_file( ) -> crate::Result { let options = ruff_workspace::pyproject::load_options(config_path)?; - Configuration::from_options(options, Some(config_path), project_root) + Configuration::from_options(options, project_root) } diff --git a/crates/ruff_wasm/src/lib.rs b/crates/ruff_wasm/src/lib.rs index 9a7e30f0df88b1..8cd9af7f6f86e3 100644 --- a/crates/ruff_wasm/src/lib.rs +++ b/crates/ruff_wasm/src/lib.rs @@ -22,7 +22,7 @@ use ruff_python_parser::{parse, parse_unchecked, parse_unchecked_source, Mode, P use ruff_source_file::{Locator, SourceLocation}; use ruff_text_size::Ranged; use ruff_workspace::configuration::Configuration; -use ruff_workspace::options::{FormatOptions, LintCommonOptions, LintOptions, Options}; +use ruff_workspace::options::{FormatOptions, LintOptions, Options}; use ruff_workspace::Settings; #[wasm_bindgen(typescript_custom_section)] @@ -108,8 +108,7 @@ impl Workspace { pub fn new(options: JsValue) -> Result { let options: Options = serde_wasm_bindgen::from_value(options).map_err(into_error)?; let configuration = - Configuration::from_options(options, Some(Path::new(".")), Path::new(".")) - .map_err(into_error)?; + Configuration::from_options(options, Path::new(".")).map_err(into_error)?; let settings = configuration .into_settings(Path::new(".")) .map_err(into_error)?; @@ -131,17 +130,13 @@ impl Workspace { target_version: Some(PythonVersion::default()), lint: Some(LintOptions { - common: LintCommonOptions { - allowed_confusables: Some(Vec::default()), - dummy_variable_rgx: Some(DUMMY_VARIABLE_RGX.as_str().to_string()), - ignore: Some(Vec::default()), - select: Some(DEFAULT_SELECTORS.to_vec()), - extend_fixable: Some(Vec::default()), - extend_select: Some(Vec::default()), - external: Some(Vec::default()), - ..LintCommonOptions::default() - }, - + allowed_confusables: Some(Vec::default()), + dummy_variable_rgx: Some(DUMMY_VARIABLE_RGX.as_str().to_string()), + ignore: Some(Vec::default()), + select: Some(DEFAULT_SELECTORS.to_vec()), + extend_fixable: Some(Vec::default()), + extend_select: Some(Vec::default()), + external: Some(Vec::default()), ..LintOptions::default() }), format: Some(FormatOptions { diff --git a/crates/ruff_workspace/src/configuration.rs b/crates/ruff_workspace/src/configuration.rs index 7cb2a5c5083fc5..0564255bab306a 100644 --- a/crates/ruff_workspace/src/configuration.rs +++ b/crates/ruff_workspace/src/configuration.rs @@ -45,9 +45,9 @@ use crate::options::{ Flake8ErrMsgOptions, Flake8GetTextOptions, Flake8ImplicitStrConcatOptions, Flake8ImportConventionsOptions, Flake8PytestStyleOptions, Flake8QuotesOptions, Flake8SelfOptions, Flake8TidyImportsOptions, Flake8TypeCheckingOptions, - Flake8UnusedArgumentsOptions, FormatOptions, IsortOptions, LintCommonOptions, LintOptions, - McCabeOptions, Options, Pep8NamingOptions, PyUpgradeOptions, PycodestyleOptions, - PydocstyleOptions, PyflakesOptions, PylintOptions, + Flake8UnusedArgumentsOptions, FormatOptions, IsortOptions, LintOptions, McCabeOptions, Options, + Pep8NamingOptions, PyUpgradeOptions, PycodestyleOptions, PydocstyleOptions, PyflakesOptions, + PylintOptions, }; use crate::settings::{ FileResolverSettings, FormatterSettings, LineEnding, Settings, EXCLUDE, INCLUDE, @@ -403,23 +403,7 @@ impl Configuration { /// Convert the [`Options`] read from the given [`Path`] into a [`Configuration`]. /// If `None` is supplied for `path`, it indicates that the `Options` instance /// was created via "inline TOML" from the `--config` flag - pub fn from_options( - options: Options, - path: Option<&Path>, - project_root: &Path, - ) -> Result { - warn_about_deprecated_top_level_lint_options(&options.lint_top_level.0, path); - - let lint = if let Some(mut lint) = options.lint { - lint.common = lint.common.combine(options.lint_top_level.0); - lint - } else { - LintOptions { - common: options.lint_top_level.0, - ..LintOptions::default() - } - }; - + pub fn from_options(options: Options, project_root: &Path) -> Result { #[allow(deprecated)] let indent_width = { if options.tab_size.is_some() { @@ -540,7 +524,7 @@ impl Configuration { // files at present. extension: None, - lint: LintConfiguration::from_options(lint, project_root)?, + lint: LintConfiguration::from_options(options.lint.unwrap_or_default(), project_root)?, format: FormatConfiguration::from_options( options.format.unwrap_or_default(), project_root, @@ -644,27 +628,25 @@ impl LintConfiguration { fn from_options(options: LintOptions, project_root: &Path) -> Result { #[allow(deprecated)] let ignore = options - .common .ignore .into_iter() .flatten() - .chain(options.common.extend_ignore.into_iter().flatten()) + .chain(options.extend_ignore.into_iter().flatten()) .collect(); #[allow(deprecated)] let unfixable = options - .common .unfixable .into_iter() .flatten() - .chain(options.common.extend_unfixable.into_iter().flatten()) + .chain(options.extend_unfixable.into_iter().flatten()) .collect(); #[allow(deprecated)] let ignore_init_module_imports = { - if options.common.ignore_init_module_imports.is_some() { + if options.ignore_init_module_imports.is_some() { warn_user_once!("The `ignore-init-module-imports` option is deprecated and will be removed in a future release. Ruff's handling of imports in `__init__.py` files has been improved (in preview) and unused imports will always be flagged."); } - options.common.ignore_init_module_imports + options.ignore_init_module_imports }; Ok(LintConfiguration { @@ -680,24 +662,22 @@ impl LintConfiguration { preview: options.preview.map(PreviewMode::from), rule_selections: vec![RuleSelection { - select: options.common.select, + select: options.select, ignore, - extend_select: options.common.extend_select.unwrap_or_default(), - fixable: options.common.fixable, + extend_select: options.extend_select.unwrap_or_default(), + fixable: options.fixable, unfixable, - extend_fixable: options.common.extend_fixable.unwrap_or_default(), + extend_fixable: options.extend_fixable.unwrap_or_default(), }], - extend_safe_fixes: options.common.extend_safe_fixes.unwrap_or_default(), - extend_unsafe_fixes: options.common.extend_unsafe_fixes.unwrap_or_default(), - allowed_confusables: options.common.allowed_confusables, + extend_safe_fixes: options.extend_safe_fixes.unwrap_or_default(), + extend_unsafe_fixes: options.extend_unsafe_fixes.unwrap_or_default(), + allowed_confusables: options.allowed_confusables, dummy_variable_rgx: options - .common .dummy_variable_rgx .map(|pattern| Regex::new(&pattern)) .transpose() .map_err(|e| anyhow!("Invalid `dummy-variable-rgx` value: {e}"))?, extend_per_file_ignores: options - .common .extend_per_file_ignores .map(|per_file_ignores| { per_file_ignores @@ -708,10 +688,10 @@ impl LintConfiguration { .collect() }) .unwrap_or_default(), - external: options.common.external, + external: options.external, ignore_init_module_imports, - explicit_preview_rules: options.common.explicit_preview_rules, - per_file_ignores: options.common.per_file_ignores.map(|per_file_ignores| { + explicit_preview_rules: options.explicit_preview_rules, + per_file_ignores: options.per_file_ignores.map(|per_file_ignores| { per_file_ignores .into_iter() .map(|(pattern, prefixes)| { @@ -719,35 +699,35 @@ impl LintConfiguration { }) .collect() }), - task_tags: options.common.task_tags, - logger_objects: options.common.logger_objects, - typing_modules: options.common.typing_modules, + task_tags: options.task_tags, + logger_objects: options.logger_objects, + typing_modules: options.typing_modules, // Plugins - flake8_annotations: options.common.flake8_annotations, - flake8_bandit: options.common.flake8_bandit, - flake8_boolean_trap: options.common.flake8_boolean_trap, - flake8_bugbear: options.common.flake8_bugbear, - flake8_builtins: options.common.flake8_builtins, - flake8_comprehensions: options.common.flake8_comprehensions, - flake8_copyright: options.common.flake8_copyright, - flake8_errmsg: options.common.flake8_errmsg, - flake8_gettext: options.common.flake8_gettext, - flake8_implicit_str_concat: options.common.flake8_implicit_str_concat, - flake8_import_conventions: options.common.flake8_import_conventions, - flake8_pytest_style: options.common.flake8_pytest_style, - flake8_quotes: options.common.flake8_quotes, - flake8_self: options.common.flake8_self, - flake8_tidy_imports: options.common.flake8_tidy_imports, - flake8_type_checking: options.common.flake8_type_checking, - flake8_unused_arguments: options.common.flake8_unused_arguments, - isort: options.common.isort, - mccabe: options.common.mccabe, - pep8_naming: options.common.pep8_naming, - pycodestyle: options.common.pycodestyle, - pydocstyle: options.common.pydocstyle, - pyflakes: options.common.pyflakes, - pylint: options.common.pylint, - pyupgrade: options.common.pyupgrade, + flake8_annotations: options.flake8_annotations, + flake8_bandit: options.flake8_bandit, + flake8_boolean_trap: options.flake8_boolean_trap, + flake8_bugbear: options.flake8_bugbear, + flake8_builtins: options.flake8_builtins, + flake8_comprehensions: options.flake8_comprehensions, + flake8_copyright: options.flake8_copyright, + flake8_errmsg: options.flake8_errmsg, + flake8_gettext: options.flake8_gettext, + flake8_implicit_str_concat: options.flake8_implicit_str_concat, + flake8_import_conventions: options.flake8_import_conventions, + flake8_pytest_style: options.flake8_pytest_style, + flake8_quotes: options.flake8_quotes, + flake8_self: options.flake8_self, + flake8_tidy_imports: options.flake8_tidy_imports, + flake8_type_checking: options.flake8_type_checking, + flake8_unused_arguments: options.flake8_unused_arguments, + isort: options.isort, + mccabe: options.mccabe, + pep8_naming: options.pep8_naming, + pycodestyle: options.pycodestyle, + pydocstyle: options.pydocstyle, + pyflakes: options.pyflakes, + pylint: options.pylint, + pyupgrade: options.pyupgrade, }) } @@ -1271,215 +1251,6 @@ pub fn resolve_src(src: &[String], project_root: &Path) -> Result> Ok(paths) } -fn warn_about_deprecated_top_level_lint_options( - top_level_options: &LintCommonOptions, - path: Option<&Path>, -) { - let mut used_options = Vec::new(); - - if top_level_options.allowed_confusables.is_some() { - used_options.push("allowed-confusables"); - } - - if top_level_options.dummy_variable_rgx.is_some() { - used_options.push("dummy-variable-rgx"); - } - - #[allow(deprecated)] - if top_level_options.extend_ignore.is_some() { - used_options.push("extend-ignore"); - } - - if top_level_options.extend_select.is_some() { - used_options.push("extend-select"); - } - - if top_level_options.extend_fixable.is_some() { - used_options.push("extend-fixable"); - } - - #[allow(deprecated)] - if top_level_options.extend_unfixable.is_some() { - used_options.push("extend-unfixable"); - } - - if top_level_options.external.is_some() { - used_options.push("external"); - } - - if top_level_options.fixable.is_some() { - used_options.push("fixable"); - } - - if top_level_options.ignore.is_some() { - used_options.push("ignore"); - } - - if top_level_options.extend_safe_fixes.is_some() { - used_options.push("extend-safe-fixes"); - } - - if top_level_options.extend_unsafe_fixes.is_some() { - used_options.push("extend-unsafe-fixes"); - } - - #[allow(deprecated)] - if top_level_options.ignore_init_module_imports.is_some() { - used_options.push("ignore-init-module-imports"); - } - - if top_level_options.logger_objects.is_some() { - used_options.push("logger-objects"); - } - - if top_level_options.select.is_some() { - used_options.push("select"); - } - - if top_level_options.explicit_preview_rules.is_some() { - used_options.push("explicit-preview-rules"); - } - - if top_level_options.task_tags.is_some() { - used_options.push("task-tags"); - } - - if top_level_options.typing_modules.is_some() { - used_options.push("typing-modules"); - } - - if top_level_options.unfixable.is_some() { - used_options.push("unfixable"); - } - - if top_level_options.flake8_annotations.is_some() { - used_options.push("flake8-annotations"); - } - - if top_level_options.flake8_bandit.is_some() { - used_options.push("flake8-bandit"); - } - - if top_level_options.flake8_boolean_trap.is_some() { - used_options.push("flake8-boolean-trap"); - } - - if top_level_options.flake8_bugbear.is_some() { - used_options.push("flake8-bugbear"); - } - - if top_level_options.flake8_builtins.is_some() { - used_options.push("flake8-builtins"); - } - - if top_level_options.flake8_comprehensions.is_some() { - used_options.push("flake8-comprehensions"); - } - - if top_level_options.flake8_copyright.is_some() { - used_options.push("flake8-copyright"); - } - - if top_level_options.flake8_errmsg.is_some() { - used_options.push("flake8-errmsg"); - } - - if top_level_options.flake8_quotes.is_some() { - used_options.push("flake8-quotes"); - } - - if top_level_options.flake8_self.is_some() { - used_options.push("flake8-self"); - } - - if top_level_options.flake8_tidy_imports.is_some() { - used_options.push("flake8-tidy-imports"); - } - - if top_level_options.flake8_type_checking.is_some() { - used_options.push("flake8-type-checking"); - } - - if top_level_options.flake8_gettext.is_some() { - used_options.push("flake8-gettext"); - } - - if top_level_options.flake8_implicit_str_concat.is_some() { - used_options.push("flake8-implicit-str-concat"); - } - - if top_level_options.flake8_import_conventions.is_some() { - used_options.push("flake8-import-conventions"); - } - - if top_level_options.flake8_pytest_style.is_some() { - used_options.push("flake8-pytest-style"); - } - - if top_level_options.flake8_unused_arguments.is_some() { - used_options.push("flake8-unused-arguments"); - } - - if top_level_options.isort.is_some() { - used_options.push("isort"); - } - - if top_level_options.mccabe.is_some() { - used_options.push("mccabe"); - } - - if top_level_options.pep8_naming.is_some() { - used_options.push("pep8-naming"); - } - - if top_level_options.pycodestyle.is_some() { - used_options.push("pycodestyle"); - } - - if top_level_options.pydocstyle.is_some() { - used_options.push("pydocstyle"); - } - - if top_level_options.pyflakes.is_some() { - used_options.push("pyflakes"); - } - - if top_level_options.pylint.is_some() { - used_options.push("pylint"); - } - - if top_level_options.pyupgrade.is_some() { - used_options.push("pyupgrade"); - } - - if top_level_options.per_file_ignores.is_some() { - used_options.push("per-file-ignores"); - } - - if top_level_options.extend_per_file_ignores.is_some() { - used_options.push("extend-per-file-ignores"); - } - - if used_options.is_empty() { - return; - } - - let options_mapping = used_options - .iter() - .map(|option| format!("- '{option}' -> 'lint.{option}'")) - .join("\n "); - - let thing_to_update = path.map_or_else( - || String::from("your `--config` CLI arguments"), - |path| format!("`{}`", fs::relativize_path(path)), - ); - - warn_user_once_by_message!( - "The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. \ - Please update the following options in {thing_to_update}:\n {options_mapping}", - ); -} - #[cfg(test)] mod tests { use std::str::FromStr; diff --git a/crates/ruff_workspace/src/options.rs b/crates/ruff_workspace/src/options.rs index f227d2dfdab67c..d8a219c543fcc6 100644 --- a/crates/ruff_workspace/src/options.rs +++ b/crates/ruff_workspace/src/options.rs @@ -30,7 +30,6 @@ use ruff_linter::{warn_user_once, RuleSelector}; use ruff_macros::{CombineOptions, OptionsMetadata}; use ruff_python_formatter::{DocstringCodeLineWidth, QuoteStyle}; -use crate::options_base::{OptionsMetadata, Visit}; use crate::settings::LineEnding; #[derive(Clone, Debug, PartialEq, Eq, Default, OptionsMetadata, Serialize, Deserialize)] @@ -433,47 +432,16 @@ pub struct Options { #[option_group] pub lint: Option, - /// The lint sections specified at the top level. - #[serde(flatten)] - pub lint_top_level: DeprecatedTopLevelLintOptions, - /// Options to configure code formatting. #[option_group] pub format: Option, } /// Configures how ruff checks your code. -/// -/// Options specified in the `lint` section take precedence over the deprecated top-level settings. #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[derive(Clone, Debug, PartialEq, Eq, Default, OptionsMetadata, Serialize, Deserialize)] #[serde(deny_unknown_fields, rename_all = "kebab-case")] pub struct LintOptions { - #[serde(flatten)] - pub common: LintCommonOptions, - - /// A list of file patterns to exclude from linting in addition to the files excluded globally (see [`exclude`](#exclude), and [`extend-exclude`](#extend-exclude)). - /// - /// Exclusions are based on globs, and can be either: - /// - /// - Single-path patterns, like `.mypy_cache` (to exclude any directory - /// named `.mypy_cache` in the tree), `foo.py` (to exclude any file named - /// `foo.py`), or `foo_*.py` (to exclude any file matching `foo_*.py` ). - /// - Relative patterns, like `directory/foo.py` (to exclude that specific - /// file) or `directory/*.py` (to exclude any Python files in - /// `directory`). Note that these paths are relative to the project root - /// (e.g., the directory containing your `pyproject.toml`). - /// - /// For more information on the glob syntax, refer to the [`globset` documentation](https://docs.rs/globset/latest/globset/#syntax). - #[option( - default = r#"[]"#, - value_type = "list[str]", - example = r#" - exclude = ["generated"] - "# - )] - pub exclude: Option>, - /// Whether to enable preview mode. When preview mode is enabled, Ruff will /// use unstable rules and fixes. #[option( @@ -485,69 +453,7 @@ pub struct LintOptions { "# )] pub preview: Option, -} - -/// Newtype wrapper for [`LintCommonOptions`] that allows customizing the JSON schema and omitting the fields from the [`OptionsMetadata`]. -#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)] -#[serde(transparent)] -pub struct DeprecatedTopLevelLintOptions(pub LintCommonOptions); - -impl OptionsMetadata for DeprecatedTopLevelLintOptions { - fn record(_visit: &mut dyn Visit) { - // Intentionally empty. Omit all fields from the documentation and instead promote the options under the `lint.` section. - // This doesn't create an empty 'common' option because the field in the `Options` struct is marked with `#[serde(flatten)]`. - // Meaning, the code here flattens no-properties into the parent, which is what we want. - } -} - -#[cfg(feature = "schemars")] -impl schemars::JsonSchema for DeprecatedTopLevelLintOptions { - fn schema_name() -> std::string::String { - "DeprecatedTopLevelLintOptions".to_owned() - } - fn schema_id() -> std::borrow::Cow<'static, str> { - std::borrow::Cow::Borrowed(std::concat!( - std::module_path!(), - "::", - "DeprecatedTopLevelLintOptions" - )) - } - fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { - use schemars::schema::Schema; - - let common_schema = LintCommonOptions::json_schema(gen); - let mut schema_obj = common_schema.into_object(); - - if let Some(object) = schema_obj.object.as_mut() { - for property in object.properties.values_mut() { - if let Schema::Object(property_object) = property { - if let Some(metadata) = &mut property_object.metadata { - metadata.deprecated = true; - } else { - property_object.metadata = Some(Box::new(schemars::schema::Metadata { - deprecated: true, - ..schemars::schema::Metadata::default() - })); - } - } - } - } - - Schema::Object(schema_obj) - } -} -// Note: This struct should be inlined into [`LintOptions`] once support for the top-level lint settings -// is removed. -// Don't add any new options to this struct. Add them to [`LintOptions`] directly to avoid exposing them in the -// global settings. -#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[derive( - Clone, Debug, PartialEq, Eq, Default, OptionsMetadata, CombineOptions, Serialize, Deserialize, -)] -#[serde(deny_unknown_fields, rename_all = "kebab-case")] -pub struct LintCommonOptions { - // WARNING: Don't add new options to this type. Add them to `LintOptions` instead. /// A list of allowed "confusable" Unicode characters to ignore when /// enforcing `RUF001`, `RUF002`, and `RUF003`. #[option( @@ -750,6 +656,27 @@ pub struct LintCommonOptions { )] pub select: Option>, + /// A list of file patterns to exclude from linting in addition to the files excluded globally (see [`exclude`](#exclude), and [`extend-exclude`](#extend-exclude)). + /// + /// Exclusions are based on globs, and can be either: + /// + /// - Single-path patterns, like `.mypy_cache` (to exclude any directory + /// named `.mypy_cache` in the tree), `foo.py` (to exclude any file named + /// `foo.py`), or `foo_*.py` (to exclude any file matching `foo_*.py` ). + /// - Relative patterns, like `directory/foo.py` (to exclude that specific + /// file) or `directory/*.py` (to exclude any Python files in + /// `directory`). Note that these paths are relative to the project root + /// (e.g., the directory containing your `pyproject.toml`). + /// + /// For more information on the glob syntax, refer to the [`globset` documentation](https://docs.rs/globset/latest/globset/#syntax). + #[option( + default = r#"[]"#, + value_type = "list[str]", + example = r#" + exclude = ["generated"] + "# + )] + pub exclude: Option>, /// Whether to require exact codes to select preview rules. When enabled, /// preview rules will not be selected by prefixes — the full code of each /// preview rule will be required to enable the rule. @@ -904,8 +831,6 @@ pub struct LintCommonOptions { #[option_group] pub pyupgrade: Option, - // WARNING: Don't add new options to this type. Add them to `LintOptions` instead. - // Tables are required to go last. /// A list of mappings from file pattern to rule codes or prefixes to /// exclude, when considering any matching files. An initial '!' negates @@ -936,7 +861,6 @@ pub struct LintCommonOptions { "# )] pub extend_per_file_ignores: Option>>, - // WARNING: Don't add new options to this type. Add them to `LintOptions` instead. } #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] diff --git a/crates/ruff_workspace/src/pyproject.rs b/crates/ruff_workspace/src/pyproject.rs index 75a6d13243f513..67f2a3f562e5ac 100644 --- a/crates/ruff_workspace/src/pyproject.rs +++ b/crates/ruff_workspace/src/pyproject.rs @@ -167,7 +167,7 @@ mod tests { use ruff_linter::line_width::LineLength; use ruff_linter::settings::types::PatternPrefixPair; - use crate::options::{LintCommonOptions, LintOptions, Options}; + use crate::options::{LintOptions, Options}; use crate::pyproject::{find_settings_toml, parse_pyproject_toml, Pyproject, Tools}; #[test] @@ -242,10 +242,7 @@ select = ["E501"] Some(Tools { ruff: Some(Options { lint: Some(LintOptions { - common: LintCommonOptions { - select: Some(vec![codes::Pycodestyle::E501.into()]), - ..LintCommonOptions::default() - }, + select: Some(vec![codes::Pycodestyle::E501.into()]), ..LintOptions::default() }), ..Options::default() @@ -266,11 +263,8 @@ ignore = ["E501"] Some(Tools { ruff: Some(Options { lint: Some(LintOptions { - common: LintCommonOptions { - extend_select: Some(vec![codes::Ruff::_100.into()]), - ignore: Some(vec![codes::Pycodestyle::E501.into()]), - ..LintCommonOptions::default() - }, + extend_select: Some(vec![codes::Ruff::_100.into()]), + ignore: Some(vec![codes::Pycodestyle::E501.into()]), ..LintOptions::default() }), ..Options::default() @@ -348,13 +342,10 @@ per-file-ignores = { "__init__.py" = ["F401"] } ]), lint: Some(LintOptions { - common: LintCommonOptions { - per_file_ignores: Some(FxHashMap::from_iter([( - "__init__.py".to_string(), - vec![codes::Pyflakes::_401.into()] - )])), - ..LintCommonOptions::default() - }, + per_file_ignores: Some(FxHashMap::from_iter([( + "__init__.py".to_string(), + vec![codes::Pyflakes::_401.into()] + )])), ..LintOptions::default() }), ..Options::default() diff --git a/crates/ruff_workspace/src/resolver.rs b/crates/ruff_workspace/src/resolver.rs index 9f8150044dde00..8d2ea420a57436 100644 --- a/crates/ruff_workspace/src/resolver.rs +++ b/crates/ruff_workspace/src/resolver.rs @@ -273,7 +273,7 @@ fn resolve_configuration( let options = pyproject::load_options(&path)?; let project_root = relativity.resolve(&path); - let configuration = Configuration::from_options(options, Some(&path), project_root)?; + let configuration = Configuration::from_options(options, project_root)?; // If extending, continue to collect. next = configuration.extend.as_ref().map(|extend| { diff --git a/ruff.schema.json b/ruff.schema.json index 15779c1222558c..1e7e5512171af3 100644 --- a/ruff.schema.json +++ b/ruff.schema.json @@ -3,19 +3,6 @@ "title": "Options", "type": "object", "properties": { - "allowed-confusables": { - "description": "A list of allowed \"confusable\" Unicode characters to ignore when enforcing `RUF001`, `RUF002`, and `RUF003`.", - "deprecated": true, - "type": [ - "array", - "null" - ], - "items": { - "type": "string", - "maxLength": 1, - "minLength": 1 - } - }, "builtins": { "description": "A list of builtins to treat as defined references, in addition to the system builtins.", "type": [ @@ -33,14 +20,6 @@ "null" ] }, - "dummy-variable-rgx": { - "description": "A regular expression used to identify \"dummy\" variables, or those which should be ignored when enforcing (e.g.) unused-variable rules. The default expression matches `_`, `__`, and `_var`, but not `_var_`.", - "deprecated": true, - "type": [ - "string", - "null" - ] - }, "exclude": { "description": "A list of file patterns to exclude from formatting and linting.\n\nExclusions are based on globs, and can be either:\n\n- Single-path patterns, like `.mypy_cache` (to exclude any directory named `.mypy_cache` in the tree), `foo.py` (to exclude any file named `foo.py`), or `foo_*.py` (to exclude any file matching `foo_*.py` ). - Relative patterns, like `directory/foo.py` (to exclude that specific file) or `directory/*.py` (to exclude any Python files in `directory`). Note that these paths are relative to the project root (e.g., the directory containing your `pyproject.toml`).\n\nFor more information on the glob syntax, refer to the [`globset` documentation](https://docs.rs/globset/latest/globset/#syntax).\n\nNote that you'll typically want to use [`extend-exclude`](#extend-exclude) to modify the excluded paths.", "type": [ @@ -51,14 +30,6 @@ "type": "string" } }, - "explicit-preview-rules": { - "description": "Whether to require exact codes to select preview rules. When enabled, preview rules will not be selected by prefixes — the full code of each preview rule will be required to enable the rule.", - "deprecated": true, - "type": [ - "boolean", - "null" - ] - }, "extend": { "description": "A path to a local `pyproject.toml` file to merge into this configuration. User home directory and environment variables will be expanded.\n\nTo resolve the current `pyproject.toml` file, Ruff will first resolve this base configuration file, then merge in any properties defined in the current configuration file.", "type": [ @@ -76,28 +47,6 @@ "type": "string" } }, - "extend-fixable": { - "description": "A list of rule codes or prefixes to consider fixable, in addition to those specified by `fixable`.", - "deprecated": true, - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/RuleSelector" - } - }, - "extend-ignore": { - "description": "A list of rule codes or prefixes to ignore, in addition to those specified by `ignore`.", - "deprecated": true, - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/RuleSelector" - } - }, "extend-include": { "description": "A list of file patterns to include when linting, in addition to those specified by `include`.\n\nInclusion are based on globs, and should be single-path patterns, like `*.pyw`, to include any file with the `.pyw` extension.\n\nFor more information on the glob syntax, refer to the [`globset` documentation](https://docs.rs/globset/latest/globset/#syntax).", "type": [ @@ -108,75 +57,6 @@ "type": "string" } }, - "extend-per-file-ignores": { - "description": "A list of mappings from file pattern to rule codes or prefixes to exclude, in addition to any rules excluded by `per-file-ignores`.", - "deprecated": true, - "type": [ - "object", - "null" - ], - "additionalProperties": { - "type": "array", - "items": { - "$ref": "#/definitions/RuleSelector" - } - } - }, - "extend-safe-fixes": { - "description": "A list of rule codes or prefixes for which unsafe fixes should be considered safe.", - "deprecated": true, - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/RuleSelector" - } - }, - "extend-select": { - "description": "A list of rule codes or prefixes to enable, in addition to those specified by `select`.", - "deprecated": true, - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/RuleSelector" - } - }, - "extend-unfixable": { - "description": "A list of rule codes or prefixes to consider non-auto-fixable, in addition to those specified by `unfixable`.", - "deprecated": true, - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/RuleSelector" - } - }, - "extend-unsafe-fixes": { - "description": "A list of rule codes or prefixes for which safe fixes should be considered unsafe.", - "deprecated": true, - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/RuleSelector" - } - }, - "external": { - "description": "A list of rule codes or prefixes that are unsupported by Ruff, but should be preserved when (e.g.) validating `# noqa` directives. Useful for retaining `# noqa` directives that cover plugins not yet implemented by Ruff.", - "deprecated": true, - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - } - }, "fix": { "description": "Enable fix behavior by-default when running `ruff` (overridden by the `--fix` and `--no-fix` command-line flags). Only includes automatic fixes unless `--unsafe-fixes` is provided.", "type": [ @@ -191,221 +71,6 @@ "null" ] }, - "fixable": { - "description": "A list of rule codes or prefixes to consider fixable. By default, all rules are considered fixable.", - "deprecated": true, - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/RuleSelector" - } - }, - "flake8-annotations": { - "description": "Options for the `flake8-annotations` plugin.", - "deprecated": true, - "anyOf": [ - { - "$ref": "#/definitions/Flake8AnnotationsOptions" - }, - { - "type": "null" - } - ] - }, - "flake8-bandit": { - "description": "Options for the `flake8-bandit` plugin.", - "deprecated": true, - "anyOf": [ - { - "$ref": "#/definitions/Flake8BanditOptions" - }, - { - "type": "null" - } - ] - }, - "flake8-boolean-trap": { - "description": "Options for the `flake8-boolean-trap` plugin.", - "deprecated": true, - "anyOf": [ - { - "$ref": "#/definitions/Flake8BooleanTrapOptions" - }, - { - "type": "null" - } - ] - }, - "flake8-bugbear": { - "description": "Options for the `flake8-bugbear` plugin.", - "deprecated": true, - "anyOf": [ - { - "$ref": "#/definitions/Flake8BugbearOptions" - }, - { - "type": "null" - } - ] - }, - "flake8-builtins": { - "description": "Options for the `flake8-builtins` plugin.", - "deprecated": true, - "anyOf": [ - { - "$ref": "#/definitions/Flake8BuiltinsOptions" - }, - { - "type": "null" - } - ] - }, - "flake8-comprehensions": { - "description": "Options for the `flake8-comprehensions` plugin.", - "deprecated": true, - "anyOf": [ - { - "$ref": "#/definitions/Flake8ComprehensionsOptions" - }, - { - "type": "null" - } - ] - }, - "flake8-copyright": { - "description": "Options for the `flake8-copyright` plugin.", - "deprecated": true, - "anyOf": [ - { - "$ref": "#/definitions/Flake8CopyrightOptions" - }, - { - "type": "null" - } - ] - }, - "flake8-errmsg": { - "description": "Options for the `flake8-errmsg` plugin.", - "deprecated": true, - "anyOf": [ - { - "$ref": "#/definitions/Flake8ErrMsgOptions" - }, - { - "type": "null" - } - ] - }, - "flake8-gettext": { - "description": "Options for the `flake8-gettext` plugin.", - "deprecated": true, - "anyOf": [ - { - "$ref": "#/definitions/Flake8GetTextOptions" - }, - { - "type": "null" - } - ] - }, - "flake8-implicit-str-concat": { - "description": "Options for the `flake8-implicit-str-concat` plugin.", - "deprecated": true, - "anyOf": [ - { - "$ref": "#/definitions/Flake8ImplicitStrConcatOptions" - }, - { - "type": "null" - } - ] - }, - "flake8-import-conventions": { - "description": "Options for the `flake8-import-conventions` plugin.", - "deprecated": true, - "anyOf": [ - { - "$ref": "#/definitions/Flake8ImportConventionsOptions" - }, - { - "type": "null" - } - ] - }, - "flake8-pytest-style": { - "description": "Options for the `flake8-pytest-style` plugin.", - "deprecated": true, - "anyOf": [ - { - "$ref": "#/definitions/Flake8PytestStyleOptions" - }, - { - "type": "null" - } - ] - }, - "flake8-quotes": { - "description": "Options for the `flake8-quotes` plugin.", - "deprecated": true, - "anyOf": [ - { - "$ref": "#/definitions/Flake8QuotesOptions" - }, - { - "type": "null" - } - ] - }, - "flake8-self": { - "description": "Options for the `flake8_self` plugin.", - "deprecated": true, - "anyOf": [ - { - "$ref": "#/definitions/Flake8SelfOptions" - }, - { - "type": "null" - } - ] - }, - "flake8-tidy-imports": { - "description": "Options for the `flake8-tidy-imports` plugin.", - "deprecated": true, - "anyOf": [ - { - "$ref": "#/definitions/Flake8TidyImportsOptions" - }, - { - "type": "null" - } - ] - }, - "flake8-type-checking": { - "description": "Options for the `flake8-type-checking` plugin.", - "deprecated": true, - "anyOf": [ - { - "$ref": "#/definitions/Flake8TypeCheckingOptions" - }, - { - "type": "null" - } - ] - }, - "flake8-unused-arguments": { - "description": "Options for the `flake8-unused-arguments` plugin.", - "deprecated": true, - "anyOf": [ - { - "$ref": "#/definitions/Flake8UnusedArgumentsOptions" - }, - { - "type": "null" - } - ] - }, "force-exclude": { "description": "Whether to enforce `exclude` and `extend-exclude` patterns, even for paths that are passed to Ruff explicitly. Typically, Ruff will lint any paths passed in directly, even if they would typically be excluded. Setting `force-exclude = true` will cause Ruff to respect these exclusions unequivocally.\n\nThis is useful for [`pre-commit`](https://pre-commit.com/), which explicitly passes all changed files to the [`ruff-pre-commit`](https://github.com/astral-sh/ruff-pre-commit) plugin, regardless of whether they're marked as excluded by Ruff's own settings.", "type": [ @@ -424,25 +89,6 @@ } ] }, - "ignore": { - "description": "A list of rule codes or prefixes to ignore. Prefixes can specify exact rules (like `F841`), entire categories (like `F`), or anything in between.\n\nWhen breaking ties between enabled and disabled rules (via `select` and `ignore`, respectively), more specific prefixes override less specific prefixes.", - "deprecated": true, - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/RuleSelector" - } - }, - "ignore-init-module-imports": { - "description": "Avoid automatically removing unused imports in `__init__.py` files. Such imports will still be flagged, but with a dedicated message suggesting that the import is either added to the module's `__all__` symbol, or re-exported with a redundant alias (e.g., `import os as os`).\n\nThis option is enabled by default, but you can opt-in to removal of imports via an unsafe fix.", - "deprecated": true, - "type": [ - "boolean", - "null" - ] - }, "include": { "description": "A list of file patterns to include when linting.\n\nInclusion are based on globs, and should be single-path patterns, like `*.pyw`, to include any file with the `.pyw` extension. `pyproject.toml` is included here not for configuration but because we lint whether e.g. the `[project]` matches the schema.\n\nFor more information on the glob syntax, refer to the [`globset` documentation](https://docs.rs/globset/latest/globset/#syntax).", "type": [ @@ -464,18 +110,6 @@ } ] }, - "isort": { - "description": "Options for the `isort` plugin.", - "deprecated": true, - "anyOf": [ - { - "$ref": "#/definitions/IsortOptions" - }, - { - "type": "null" - } - ] - }, "line-length": { "description": "The line length to use when enforcing long-lines violations (like `E501`) and at which `isort` and the formatter prefers to wrap lines.\n\nThe length is determined by the number of characters per line, except for lines containing East Asian characters or emojis. For these lines, the [unicode width](https://unicode.org/reports/tr11/) of each character is added up to determine the length.\n\nThe value must be greater than `0` and less than or equal to `320`.\n\nNote: While the formatter will attempt to format lines such that they remain within the `line-length`, it isn't a hard upper bound, and formatted lines may exceed the `line-length`.\n\nSee [`pycodestyle.max-line-length`](#lint_pycodestyle_max-line-length) to configure different lengths for `E501` and the formatter.", "anyOf": [ @@ -497,29 +131,6 @@ } ] }, - "logger-objects": { - "description": "A list of objects that should be treated equivalently to a `logging.Logger` object.\n\nThis is useful for ensuring proper diagnostics (e.g., to identify `logging` deprecations and other best-practices) for projects that re-export a `logging.Logger` object from a common module.\n\nFor example, if you have a module `logging_setup.py` with the following contents: ```python import logging\n\nlogger = logging.getLogger(__name__) ```\n\nAdding `\"logging_setup.logger\"` to `logger-objects` will ensure that `logging_setup.logger` is treated as a `logging.Logger` object when imported from other modules (e.g., `from logging_setup import logger`).", - "deprecated": true, - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - } - }, - "mccabe": { - "description": "Options for the `mccabe` plugin.", - "deprecated": true, - "anyOf": [ - { - "$ref": "#/definitions/McCabeOptions" - }, - { - "type": "null" - } - ] - }, "namespace-packages": { "description": "Mark the specified directories as namespace packages. For the purpose of module resolution, Ruff will treat those directories and all their subdirectories as if they contained an `__init__.py` file.", "type": [ @@ -541,32 +152,6 @@ } ] }, - "pep8-naming": { - "description": "Options for the `pep8-naming` plugin.", - "deprecated": true, - "anyOf": [ - { - "$ref": "#/definitions/Pep8NamingOptions" - }, - { - "type": "null" - } - ] - }, - "per-file-ignores": { - "description": "A list of mappings from file pattern to rule codes or prefixes to exclude, when considering any matching files. An initial '!' negates the file pattern.", - "deprecated": true, - "type": [ - "object", - "null" - ], - "additionalProperties": { - "type": "array", - "items": { - "$ref": "#/definitions/RuleSelector" - } - } - }, "preview": { "description": "Whether to enable preview mode. When preview mode is enabled, Ruff will use unstable rules, fixes, and formatting.", "type": [ @@ -574,66 +159,6 @@ "null" ] }, - "pycodestyle": { - "description": "Options for the `pycodestyle` plugin.", - "deprecated": true, - "anyOf": [ - { - "$ref": "#/definitions/PycodestyleOptions" - }, - { - "type": "null" - } - ] - }, - "pydocstyle": { - "description": "Options for the `pydocstyle` plugin.", - "deprecated": true, - "anyOf": [ - { - "$ref": "#/definitions/PydocstyleOptions" - }, - { - "type": "null" - } - ] - }, - "pyflakes": { - "description": "Options for the `pyflakes` plugin.", - "deprecated": true, - "anyOf": [ - { - "$ref": "#/definitions/PyflakesOptions" - }, - { - "type": "null" - } - ] - }, - "pylint": { - "description": "Options for the `pylint` plugin.", - "deprecated": true, - "anyOf": [ - { - "$ref": "#/definitions/PylintOptions" - }, - { - "type": "null" - } - ] - }, - "pyupgrade": { - "description": "Options for the `pyupgrade` plugin.", - "deprecated": true, - "anyOf": [ - { - "$ref": "#/definitions/PyUpgradeOptions" - }, - { - "type": "null" - } - ] - }, "required-version": { "description": "Enforce a requirement on the version of Ruff, to enforce at runtime. If the version of Ruff does not meet the requirement, Ruff will exit with an error.\n\nUseful for unifying results across many environments, e.g., with a `pyproject.toml` file.\n\nAccepts a PEP 440 specifier, like `==0.3.1` or `>=0.3.1`.", "anyOf": [ @@ -652,17 +177,6 @@ "null" ] }, - "select": { - "description": "A list of rule codes or prefixes to enable. Prefixes can specify exact rules (like `F841`), entire categories (like `F`), or anything in between.\n\nWhen breaking ties between enabled and disabled rules (via `select` and `ignore`, respectively), more specific prefixes override less specific prefixes.", - "deprecated": true, - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/RuleSelector" - } - }, "show-fixes": { "description": "Whether to show an enumeration of all fixed lint violations (overridden by the `--show-fixes` command-line flag).", "type": [ @@ -711,39 +225,6 @@ } ] }, - "task-tags": { - "description": "A list of task tags to recognize (e.g., \"TODO\", \"FIXME\", \"XXX\").\n\nComments starting with these tags will be ignored by commented-out code detection (`ERA`), and skipped by line-length rules (`E501`) if `ignore-overlong-task-comments` is set to `true`.", - "deprecated": true, - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - } - }, - "typing-modules": { - "description": "A list of modules whose exports should be treated equivalently to members of the `typing` module.\n\nThis is useful for ensuring proper type annotation inference for projects that re-export `typing` and `typing_extensions` members from a compatibility module. If omitted, any members imported from modules apart from `typing` and `typing_extensions` will be treated as ordinary Python objects.", - "deprecated": true, - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - } - }, - "unfixable": { - "description": "A list of rule codes or prefixes to consider non-fixable.", - "deprecated": true, - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/RuleSelector" - } - }, "unsafe-fixes": { "description": "Enable application of unsafe fixes. If excluded, a hint will be displayed when unsafe fixes are available. If set to false, the hint will be hidden.", "type": [ @@ -1786,7 +1267,7 @@ "minimum": 1.0 }, "LintOptions": { - "description": "Configures how ruff checks your code.\n\nOptions specified in the `lint` section take precedence over the deprecated top-level settings.", + "description": "Configures how ruff checks your code.", "type": "object", "properties": { "allowed-confusables": {