From a62a3a41afe4f0bba75cc4b948211a1644502782 Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Wed, 20 Sep 2023 18:03:07 +0200 Subject: [PATCH] Add `lint` section to Ruff configuration --- crates/flake8_to_ruff/src/converter.rs | 105 +-- ...ation_test__explain_status_codes_f401.snap | 2 +- crates/ruff_dev/src/generate_docs.rs | 16 +- .../eradicate/rules/commented_out_code.rs | 2 +- .../function_call_in_argument_default.rs | 2 +- .../rules/mutable_argument_default.rs | 2 +- .../rules/builtin_argument_shadowing.rs | 2 +- .../rules/builtin_attribute_shadowing.rs | 2 +- .../rules/builtin_variable_shadowing.rs | 2 +- .../rules/implicit.rs | 2 +- .../rules/flake8_logging_format/violations.rs | 16 +- .../flake8_pytest_style/rules/fixture.rs | 2 +- .../rules/flake8_pytest_style/rules/marks.rs | 2 +- .../flake8_pytest_style/rules/parametrize.rs | 6 +- .../rules/flake8_pytest_style/rules/raises.rs | 4 +- .../rules/flake8_quotes/rules/from_tokens.rs | 6 +- .../rules/private_member_access.rs | 2 +- .../flake8_tidy_imports/rules/banned_api.rs | 2 +- .../rules/banned_module_level_imports.rs | 2 +- .../rules/relative_imports.rs | 2 +- .../rules/typing_only_runtime_import.rs | 12 +- .../mccabe/rules/function_is_too_complex.rs | 2 +- ...id_first_argument_name_for_class_method.rs | 6 +- .../invalid_first_argument_name_for_method.rs | 6 +- .../rules/invalid_function_name.rs | 2 +- .../non_lowercase_variable_in_function.rs | 2 +- .../pycodestyle/rules/doc_line_too_long.rs | 6 +- .../rules/pycodestyle/rules/line_too_long.rs | 4 +- .../rules/blank_before_after_class.rs | 6 +- .../pydocstyle/rules/ends_with_period.rs | 2 +- .../pydocstyle/rules/ends_with_punctuation.rs | 2 +- .../rules/pydocstyle/rules/no_signature.rs | 2 +- .../pydocstyle/rules/non_imperative_mood.rs | 2 +- .../src/rules/pydocstyle/rules/sections.rs | 28 +- .../pydocstyle/rules/starts_with_this.rs | 2 +- .../src/rules/pyflakes/rules/unused_import.rs | 2 +- .../rules/pyflakes/rules/unused_variable.rs | 2 +- .../rules/pylint/rules/too_many_arguments.rs | 2 +- .../rules/pylint/rules/too_many_branches.rs | 2 +- .../pylint/rules/too_many_public_methods.rs | 2 +- .../rules/too_many_return_statements.rs | 2 +- .../rules/pylint/rules/too_many_statements.rs | 2 +- .../pyupgrade/rules/use_pep585_annotation.rs | 2 +- .../pyupgrade/rules/use_pep604_annotation.rs | 2 +- .../function_call_in_dataclass_default.rs | 2 +- crates/ruff_wasm/src/lib.rs | 38 +- crates/ruff_workspace/src/configuration.rs | 191 +++--- crates/ruff_workspace/src/options.rs | 626 +++++++++--------- crates/ruff_workspace/src/pyproject.rs | 26 +- ruff.schema.json | 423 ++++++++++++ 50 files changed, 1032 insertions(+), 557 deletions(-) diff --git a/crates/flake8_to_ruff/src/converter.rs b/crates/flake8_to_ruff/src/converter.rs index 0caafa0b54df59..4b6693d9c4d963 100644 --- a/crates/flake8_to_ruff/src/converter.rs +++ b/crates/flake8_to_ruff/src/converter.rs @@ -16,8 +16,8 @@ use ruff_linter::settings::types::PythonVersion; use ruff_linter::warn_user; use ruff_workspace::options::{ Flake8AnnotationsOptions, Flake8BugbearOptions, Flake8BuiltinsOptions, Flake8ErrMsgOptions, - Flake8PytestStyleOptions, Flake8QuotesOptions, Flake8TidyImportsOptions, McCabeOptions, - Options, Pep8NamingOptions, PydocstyleOptions, + Flake8PytestStyleOptions, Flake8QuotesOptions, Flake8TidyImportsOptions, LintOptions, + McCabeOptions, Options, Pep8NamingOptions, PydocstyleOptions, }; use ruff_workspace::pyproject::Pyproject; @@ -103,6 +103,7 @@ pub(crate) fn convert( // Parse each supported option. let mut options = Options::default(); + let mut lint_options = LintOptions::default(); let mut flake8_annotations = Flake8AnnotationsOptions::default(); let mut flake8_bugbear = Flake8BugbearOptions::default(); let mut flake8_builtins = Flake8BuiltinsOptions::default(); @@ -150,7 +151,7 @@ pub(crate) fn convert( "per-file-ignores" | "per_file_ignores" => { match parser::parse_files_to_codes_mapping(value.as_ref()) { Ok(per_file_ignores) => { - options.per_file_ignores = + lint_options.per_file_ignores = Some(parser::collect_per_file_ignores(per_file_ignores)); } Err(e) => { @@ -358,47 +359,47 @@ pub(crate) fn convert( } // Deduplicate and sort. - options.select = Some( + lint_options.select = Some( select .into_iter() .sorted_by_key(RuleSelector::prefix_and_code) .collect(), ); - options.ignore = Some( + lint_options.ignore = Some( ignore .into_iter() .sorted_by_key(RuleSelector::prefix_and_code) .collect(), ); if flake8_annotations != Flake8AnnotationsOptions::default() { - options.flake8_annotations = Some(flake8_annotations); + lint_options.flake8_annotations = Some(flake8_annotations); } if flake8_bugbear != Flake8BugbearOptions::default() { - options.flake8_bugbear = Some(flake8_bugbear); + lint_options.flake8_bugbear = Some(flake8_bugbear); } if flake8_builtins != Flake8BuiltinsOptions::default() { - options.flake8_builtins = Some(flake8_builtins); + lint_options.flake8_builtins = Some(flake8_builtins); } if flake8_errmsg != Flake8ErrMsgOptions::default() { - options.flake8_errmsg = Some(flake8_errmsg); + lint_options.flake8_errmsg = Some(flake8_errmsg); } if flake8_pytest_style != Flake8PytestStyleOptions::default() { - options.flake8_pytest_style = Some(flake8_pytest_style); + lint_options.flake8_pytest_style = Some(flake8_pytest_style); } if flake8_quotes != Flake8QuotesOptions::default() { - options.flake8_quotes = Some(flake8_quotes); + lint_options.flake8_quotes = Some(flake8_quotes); } if flake8_tidy_imports != Flake8TidyImportsOptions::default() { - options.flake8_tidy_imports = Some(flake8_tidy_imports); + lint_options.flake8_tidy_imports = Some(flake8_tidy_imports); } if mccabe != McCabeOptions::default() { - options.mccabe = Some(mccabe); + lint_options.mccabe = Some(mccabe); } if pep8_naming != Pep8NamingOptions::default() { - options.pep8_naming = Some(pep8_naming); + lint_options.pep8_naming = Some(pep8_naming); } if pydocstyle != PydocstyleOptions::default() { - options.pydocstyle = Some(pydocstyle); + lint_options.pydocstyle = Some(pydocstyle); } // Extract any settings from the existing `pyproject.toml`. @@ -436,6 +437,10 @@ pub(crate) fn convert( } } + if lint_options != LintOptions::default() { + options.lint = Some(lint_options); + } + // Create the pyproject.toml. Pyproject::new(options) } @@ -464,7 +469,7 @@ mod tests { use ruff_linter::rules::flake8_quotes; use ruff_linter::rules::pydocstyle::settings::Convention; use ruff_linter::settings::types::PythonVersion; - use ruff_workspace::options::{Flake8QuotesOptions, Options, PydocstyleOptions}; + use ruff_workspace::options::{Flake8QuotesOptions, LintOptions, Options, PydocstyleOptions}; use ruff_workspace::pyproject::Pyproject; use crate::converter::DEFAULT_SELECTORS; @@ -474,8 +479,8 @@ mod tests { use super::super::plugin::Plugin; use super::convert; - fn default_options(plugins: impl IntoIterator) -> Options { - Options { + fn lint_default_options(plugins: impl IntoIterator) -> LintOptions { + LintOptions { ignore: Some(vec![]), select: Some( DEFAULT_SELECTORS @@ -485,7 +490,7 @@ mod tests { .sorted_by_key(RuleSelector::prefix_and_code) .collect(), ), - ..Options::default() + ..LintOptions::default() } } @@ -496,7 +501,10 @@ mod tests { &ExternalConfig::default(), None, ); - let expected = Pyproject::new(default_options([])); + let expected = Pyproject::new(Options { + lint: Some(lint_default_options([])), + ..Options::default() + }); assert_eq!(actual, expected); } @@ -512,7 +520,8 @@ mod tests { ); let expected = Pyproject::new(Options { line_length: Some(LineLength::try_from(100).unwrap()), - ..default_options([]) + lint: Some(lint_default_options([])), + ..Options::default() }); assert_eq!(actual, expected); } @@ -529,7 +538,8 @@ mod tests { ); let expected = Pyproject::new(Options { line_length: Some(LineLength::try_from(100).unwrap()), - ..default_options([]) + lint: Some(lint_default_options([])), + ..Options::default() }); assert_eq!(actual, expected); } @@ -544,7 +554,10 @@ mod tests { &ExternalConfig::default(), Some(vec![]), ); - let expected = Pyproject::new(default_options([])); + let expected = Pyproject::new(Options { + lint: Some(lint_default_options([])), + ..Options::default() + }); assert_eq!(actual, expected); } @@ -559,13 +572,16 @@ mod tests { Some(vec![]), ); let expected = Pyproject::new(Options { - flake8_quotes: Some(Flake8QuotesOptions { - inline_quotes: Some(flake8_quotes::settings::Quote::Single), - multiline_quotes: None, - docstring_quotes: None, - avoid_escape: None, + lint: Some(LintOptions { + flake8_quotes: Some(Flake8QuotesOptions { + inline_quotes: Some(flake8_quotes::settings::Quote::Single), + multiline_quotes: None, + docstring_quotes: None, + avoid_escape: None, + }), + ..lint_default_options([]) }), - ..default_options([]) + ..Options::default() }); assert_eq!(actual, expected); } @@ -584,12 +600,15 @@ mod tests { Some(vec![Plugin::Flake8Docstrings]), ); let expected = Pyproject::new(Options { - pydocstyle: Some(PydocstyleOptions { - convention: Some(Convention::Numpy), - ignore_decorators: None, - property_decorators: None, + lint: Some(LintOptions { + pydocstyle: Some(PydocstyleOptions { + convention: Some(Convention::Numpy), + ignore_decorators: None, + property_decorators: None, + }), + ..lint_default_options([Linter::Pydocstyle.into()]) }), - ..default_options([Linter::Pydocstyle.into()]) + ..Options::default() }); assert_eq!(actual, expected); } @@ -605,13 +624,16 @@ mod tests { None, ); let expected = Pyproject::new(Options { - flake8_quotes: Some(Flake8QuotesOptions { - inline_quotes: Some(flake8_quotes::settings::Quote::Single), - multiline_quotes: None, - docstring_quotes: None, - avoid_escape: None, + lint: Some(LintOptions { + flake8_quotes: Some(Flake8QuotesOptions { + inline_quotes: Some(flake8_quotes::settings::Quote::Single), + multiline_quotes: None, + docstring_quotes: None, + avoid_escape: None, + }), + ..lint_default_options([Linter::Flake8Quotes.into()]) }), - ..default_options([Linter::Flake8Quotes.into()]) + ..Options::default() }); assert_eq!(actual, expected); } @@ -630,7 +652,8 @@ mod tests { ); let expected = Pyproject::new(Options { target_version: Some(PythonVersion::Py38), - ..default_options([]) + lint: Some(lint_default_options([])), + ..Options::default() }); assert_eq!(actual, expected); diff --git a/crates/ruff_cli/tests/snapshots/integration_test__explain_status_codes_f401.snap b/crates/ruff_cli/tests/snapshots/integration_test__explain_status_codes_f401.snap index 17615bf57049e1..21f4c24801fb57 100644 --- a/crates/ruff_cli/tests/snapshots/integration_test__explain_status_codes_f401.snap +++ b/crates/ruff_cli/tests/snapshots/integration_test__explain_status_codes_f401.snap @@ -51,7 +51,7 @@ else: ``` ## Options -- `pyflakes.extend-generics` +- `lint.pyflakes.extend-generics` ## References - [Python documentation: `import`](https://docs.python.org/3/reference/simple_stmts.html#the-import-statement) diff --git a/crates/ruff_dev/src/generate_docs.rs b/crates/ruff_dev/src/generate_docs.rs index 3cbb295509513a..00a52ac36c97b3 100644 --- a/crates/ruff_dev/src/generate_docs.rs +++ b/crates/ruff_dev/src/generate_docs.rs @@ -127,13 +127,13 @@ mod tests { let mut output = String::new(); process_documentation( " -See also [`mccabe.max-complexity`] and [`task-tags`]. +See also [`lint.mccabe.max-complexity`] and [`lint.task-tags`]. Something [`else`][other]. ## Options -- `task-tags` -- `mccabe.max-complexity` +- `lint.task-tags` +- `lint.mccabe.max-complexity` [other]: http://example.com.", &mut output, @@ -141,18 +141,18 @@ Something [`else`][other]. assert_eq!( output, " -See also [`mccabe.max-complexity`][mccabe.max-complexity] and [`task-tags`][task-tags]. +See also [`lint.mccabe.max-complexity`][lint.mccabe.max-complexity] and [`lint.task-tags`][lint.task-tags]. Something [`else`][other]. ## Options -- [`task-tags`][task-tags] -- [`mccabe.max-complexity`][mccabe.max-complexity] +- [`lint.task-tags`][lint.task-tags] +- [`lint.mccabe.max-complexity`][lint.mccabe.max-complexity] [other]: http://example.com. -[task-tags]: ../settings.md#task-tags -[mccabe.max-complexity]: ../settings.md#mccabe-max-complexity +[lint.task-tags]: ../settings.md#lint-task-tags +[lint.mccabe.max-complexity]: ../settings.md#lint-mccabe-max-complexity " ); } diff --git a/crates/ruff_linter/src/rules/eradicate/rules/commented_out_code.rs b/crates/ruff_linter/src/rules/eradicate/rules/commented_out_code.rs index 7c712f20a167e2..220929dfb12886 100644 --- a/crates/ruff_linter/src/rules/eradicate/rules/commented_out_code.rs +++ b/crates/ruff_linter/src/rules/eradicate/rules/commented_out_code.rs @@ -21,7 +21,7 @@ use super::super::detection::comment_contains_code; /// ``` /// /// ## Options -/// - `task-tags` +/// - `lint.task-tags` #[violation] pub struct CommentedOutCode; diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/rules/function_call_in_argument_default.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/function_call_in_argument_default.rs index 964026d5f09e0c..2950c56a5d20f7 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/rules/function_call_in_argument_default.rs +++ b/crates/ruff_linter/src/rules/flake8_bugbear/rules/function_call_in_argument_default.rs @@ -51,7 +51,7 @@ use crate::checkers::ast::Checker; /// ``` /// /// ## Options -/// - `flake8-bugbear.extend-immutable-calls` +/// - `lint.flake8-bugbear.extend-immutable-calls` #[violation] pub struct FunctionCallInDefaultArgument { name: Option, diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/rules/mutable_argument_default.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/mutable_argument_default.rs index f604d18d0c887c..b0d0a78cb2af3f 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/rules/mutable_argument_default.rs +++ b/crates/ruff_linter/src/rules/flake8_bugbear/rules/mutable_argument_default.rs @@ -56,7 +56,7 @@ use crate::registry::AsRule; /// ``` /// /// ## Options -/// - `flake8-bugbear.extend-immutable-calls` +/// - `lint.flake8-bugbear.extend-immutable-calls` /// /// ## References /// - [Python documentation: Default Argument Values](https://docs.python.org/3/tutorial/controlflow.html#default-argument-values) diff --git a/crates/ruff_linter/src/rules/flake8_builtins/rules/builtin_argument_shadowing.rs b/crates/ruff_linter/src/rules/flake8_builtins/rules/builtin_argument_shadowing.rs index 9406879f2fff5e..6e91d458e2021f 100644 --- a/crates/ruff_linter/src/rules/flake8_builtins/rules/builtin_argument_shadowing.rs +++ b/crates/ruff_linter/src/rules/flake8_builtins/rules/builtin_argument_shadowing.rs @@ -44,7 +44,7 @@ use super::super::helpers::shadows_builtin; /// ``` /// /// ## Options -/// - `flake8-builtins.builtins-ignorelist` +/// - `lint.flake8-builtins.builtins-ignorelist` /// /// ## References /// - [_Is it bad practice to use a built-in function name as an attribute or method identifier?_](https://stackoverflow.com/questions/9109333/is-it-bad-practice-to-use-a-built-in-function-name-as-an-attribute-or-method-ide) diff --git a/crates/ruff_linter/src/rules/flake8_builtins/rules/builtin_attribute_shadowing.rs b/crates/ruff_linter/src/rules/flake8_builtins/rules/builtin_attribute_shadowing.rs index baf682a11011d6..25ef826cd756a0 100644 --- a/crates/ruff_linter/src/rules/flake8_builtins/rules/builtin_attribute_shadowing.rs +++ b/crates/ruff_linter/src/rules/flake8_builtins/rules/builtin_attribute_shadowing.rs @@ -49,7 +49,7 @@ use crate::rules::flake8_builtins::helpers::shadows_builtin; /// ``` /// /// ## Options -/// - `flake8-builtins.builtins-ignorelist` +/// - `lint.flake8-builtins.builtins-ignorelist` /// /// ## References /// - [_Is it bad practice to use a built-in function name as an attribute or method identifier?_](https://stackoverflow.com/questions/9109333/is-it-bad-practice-to-use-a-built-in-function-name-as-an-attribute-or-method-ide) diff --git a/crates/ruff_linter/src/rules/flake8_builtins/rules/builtin_variable_shadowing.rs b/crates/ruff_linter/src/rules/flake8_builtins/rules/builtin_variable_shadowing.rs index 74aa7c2e25f0af..b8bc9110e1820b 100644 --- a/crates/ruff_linter/src/rules/flake8_builtins/rules/builtin_variable_shadowing.rs +++ b/crates/ruff_linter/src/rules/flake8_builtins/rules/builtin_variable_shadowing.rs @@ -41,7 +41,7 @@ use crate::rules::flake8_builtins::helpers::shadows_builtin; /// ``` /// /// ## Options -/// - `flake8-builtins.builtins-ignorelist` +/// - `lint.flake8-builtins.builtins-ignorelist` /// /// ## References /// - [_Why is it a bad idea to name a variable `id` in Python?_](https://stackoverflow.com/questions/77552/id-is-a-bad-variable-name-in-python) diff --git a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/rules/implicit.rs b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/rules/implicit.rs index 0a2e381a55a9a1..8718863fb2215e 100644 --- a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/rules/implicit.rs +++ b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/rules/implicit.rs @@ -75,7 +75,7 @@ impl Violation for SingleLineImplicitStringConcatenation { /// ``` /// /// ## Options -/// - `flake8-implicit-str-concat.allow-multiline` +/// - `lint.flake8-implicit-str-concat.allow-multiline` /// /// [PEP 8]: https://peps.python.org/pep-0008/#maximum-line-length #[violation] diff --git a/crates/ruff_linter/src/rules/flake8_logging_format/violations.rs b/crates/ruff_linter/src/rules/flake8_logging_format/violations.rs index 77a96c7fce53f2..1662aa2e22c32d 100644 --- a/crates/ruff_linter/src/rules/flake8_logging_format/violations.rs +++ b/crates/ruff_linter/src/rules/flake8_logging_format/violations.rs @@ -68,7 +68,7 @@ use ruff_macros::{derive_message_formats, violation}; /// ``` /// /// ## Options -/// - `logger-objects` +/// - `lint.logger-objects` /// /// ## References /// - [Python documentation: `logging`](https://docs.python.org/3/library/logging.html) @@ -152,7 +152,7 @@ impl Violation for LoggingStringFormat { /// ``` /// /// ## Options -/// - `logger-objects` +/// - `lint.logger-objects` /// /// ## References /// - [Python documentation: `logging`](https://docs.python.org/3/library/logging.html) @@ -235,7 +235,7 @@ impl Violation for LoggingPercentFormat { /// ``` /// /// ## Options -/// - `logger-objects` +/// - `lint.logger-objects` /// /// ## References /// - [Python documentation: `logging`](https://docs.python.org/3/library/logging.html) @@ -317,7 +317,7 @@ impl Violation for LoggingStringConcat { /// ``` /// /// ## Options -/// - `logger-objects` +/// - `lint.logger-objects` /// /// ## References /// - [Python documentation: `logging`](https://docs.python.org/3/library/logging.html) @@ -368,7 +368,7 @@ impl Violation for LoggingFString { /// ``` /// /// ## Options -/// - `logger-objects` +/// - `lint.logger-objects` /// /// ## References /// - [Python documentation: `logging.warning`](https://docs.python.org/3/library/logging.html#logging.warning) @@ -436,7 +436,7 @@ impl AlwaysAutofixableViolation for LoggingWarn { /// ``` /// /// ## Options -/// - `logger-objects` +/// - `lint.logger-objects` /// /// ## References /// - [Python documentation: LogRecord attributes](https://docs.python.org/3/library/logging.html#logrecord-attributes) @@ -495,7 +495,7 @@ impl Violation for LoggingExtraAttrClash { /// ``` /// /// ## Options -/// - `logger-objects` +/// - `lint.logger-objects` /// /// ## References /// - [Python documentation: `logging.exception`](https://docs.python.org/3/library/logging.html#logging.exception) @@ -556,7 +556,7 @@ impl Violation for LoggingExcInfo { /// ``` /// /// ## Options -/// - `logger-objects` +/// - `lint.logger-objects` /// /// ## References /// - [Python documentation: `logging.exception`](https://docs.python.org/3/library/logging.html#logging.exception) diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/rules/fixture.rs b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/fixture.rs index 4e401c6b44d12a..ff805cd7e38adf 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/rules/fixture.rs +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/fixture.rs @@ -55,7 +55,7 @@ use super::helpers::{ /// ``` /// /// ## Options -/// - `flake8-pytest-style.fixture-parentheses` +/// - `lint.flake8-pytest-style.fixture-parentheses` /// /// ## References /// - [`pytest` documentation: API Reference: Fixtures](https://docs.pytest.org/en/latest/reference/reference.html#fixtures-api) diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/rules/marks.rs b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/marks.rs index 01a3d3fc60da49..619db8f87cce72 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/rules/marks.rs +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/marks.rs @@ -43,7 +43,7 @@ use super::helpers::get_mark_decorators; /// ``` /// /// ## Options -/// - `flake8-pytest-style.mark-parentheses` +/// - `lint.flake8-pytest-style.mark-parentheses` /// /// ## References /// - [`pytest` documentation: Marks](https://docs.pytest.org/en/latest/reference/reference.html#marks) diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs index 293c4b8f08c753..b09919773f9f9e 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs @@ -67,7 +67,7 @@ use super::helpers::{is_pytest_parametrize, split_names}; /// ``` /// /// ## Options -/// - `flake8-pytest-style.parametrize-names-type` +/// - `lint.flake8-pytest-style.parametrize-names-type` /// /// ## References /// - [`pytest` documentation: How to parametrize fixtures and test functions](https://docs.pytest.org/en/latest/how-to/parametrize.html#pytest-mark-parametrize) @@ -170,8 +170,8 @@ impl Violation for PytestParametrizeNamesWrongType { /// ``` /// /// ## Options -/// - `flake8-pytest-style.parametrize-values-type` -/// - `flake8-pytest-style.parametrize-values-row-type` +/// - `lint.flake8-pytest-style.parametrize-values-type` +/// - `lint.flake8-pytest-style.parametrize-values-row-type` /// /// ## References /// - [`pytest` documentation: How to parametrize fixtures and test functions](https://docs.pytest.org/en/latest/how-to/parametrize.html#pytest-mark-parametrize) diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/rules/raises.rs b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/raises.rs index ec457155bd1e4b..88852b1fa10a23 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/rules/raises.rs +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/raises.rs @@ -92,8 +92,8 @@ impl Violation for PytestRaisesWithMultipleStatements { /// ``` /// /// ## Options -/// - `flake8-pytest-style.raises-require-match-for` -/// - `flake8-pytest-style.raises-extend-require-match-for` +/// - `lint.flake8-pytest-style.raises-require-match-for` +/// - `lint.flake8-pytest-style.raises-extend-require-match-for` /// /// ## References /// - [`pytest` documentation: `pytest.raises`](https://docs.pytest.org/en/latest/reference/reference.html#pytest-raises) diff --git a/crates/ruff_linter/src/rules/flake8_quotes/rules/from_tokens.rs b/crates/ruff_linter/src/rules/flake8_quotes/rules/from_tokens.rs index 7cb159008147a0..a218d45dd38b72 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/rules/from_tokens.rs +++ b/crates/ruff_linter/src/rules/flake8_quotes/rules/from_tokens.rs @@ -31,7 +31,7 @@ use super::super::settings::Quote; /// ``` /// /// ## Options -/// - `flake8-quotes.inline-quotes` +/// - `lint.flake8-quotes.inline-quotes` #[violation] pub struct BadQuotesInlineString { quote: Quote, @@ -80,7 +80,7 @@ impl AlwaysAutofixableViolation for BadQuotesInlineString { /// ``` /// /// ## Options -/// - `flake8-quotes.multiline-quotes` +/// - `lint.flake8-quotes.multiline-quotes` #[violation] pub struct BadQuotesMultilineString { quote: Quote, @@ -128,7 +128,7 @@ impl AlwaysAutofixableViolation for BadQuotesMultilineString { /// ``` /// /// ## Options -/// - `flake8-quotes.docstring-quotes` +/// - `lint.flake8-quotes.docstring-quotes` #[violation] pub struct BadQuotesDocstring { quote: Quote, diff --git a/crates/ruff_linter/src/rules/flake8_self/rules/private_member_access.rs b/crates/ruff_linter/src/rules/flake8_self/rules/private_member_access.rs index 543c4d36d73486..473d0355ab28c1 100644 --- a/crates/ruff_linter/src/rules/flake8_self/rules/private_member_access.rs +++ b/crates/ruff_linter/src/rules/flake8_self/rules/private_member_access.rs @@ -43,7 +43,7 @@ use crate::checkers::ast::Checker; /// ``` /// /// ## Options -/// - `flake8-self.ignore-names` +/// - `lint.flake8-self.ignore-names` /// /// ## References /// - [_What is the meaning of single or double underscores before an object name?_](https://stackoverflow.com/questions/1301346/what-is-the-meaning-of-single-and-double-underscore-before-an-object-name) diff --git a/crates/ruff_linter/src/rules/flake8_tidy_imports/rules/banned_api.rs b/crates/ruff_linter/src/rules/flake8_tidy_imports/rules/banned_api.rs index 98ea3ab4888870..fe3bdbada0a912 100644 --- a/crates/ruff_linter/src/rules/flake8_tidy_imports/rules/banned_api.rs +++ b/crates/ruff_linter/src/rules/flake8_tidy_imports/rules/banned_api.rs @@ -24,7 +24,7 @@ use crate::rules::flake8_tidy_imports::matchers::NameMatchPolicy; /// automatic way. /// /// ## Options -/// - `flake8-tidy-imports.banned-api` +/// - `lint.flake8-tidy-imports.banned-api` #[violation] pub struct BannedApi { name: String, diff --git a/crates/ruff_linter/src/rules/flake8_tidy_imports/rules/banned_module_level_imports.rs b/crates/ruff_linter/src/rules/flake8_tidy_imports/rules/banned_module_level_imports.rs index 61c00065445539..53b2601bea26e1 100644 --- a/crates/ruff_linter/src/rules/flake8_tidy_imports/rules/banned_module_level_imports.rs +++ b/crates/ruff_linter/src/rules/flake8_tidy_imports/rules/banned_module_level_imports.rs @@ -38,7 +38,7 @@ use crate::rules::flake8_tidy_imports::matchers::NameMatchPolicy; /// ``` /// /// ## Options -/// - `flake8-tidy-imports.banned-module-level-imports` +/// - `lint.flake8-tidy-imports.banned-module-level-imports` #[violation] pub struct BannedModuleLevelImports { name: String, diff --git a/crates/ruff_linter/src/rules/flake8_tidy_imports/rules/relative_imports.rs b/crates/ruff_linter/src/rules/flake8_tidy_imports/rules/relative_imports.rs index 30947874c9b475..20236415c7f930 100644 --- a/crates/ruff_linter/src/rules/flake8_tidy_imports/rules/relative_imports.rs +++ b/crates/ruff_linter/src/rules/flake8_tidy_imports/rules/relative_imports.rs @@ -42,7 +42,7 @@ use crate::rules::flake8_tidy_imports::settings::Strictness; /// ``` /// /// ## Options -/// - `flake8-tidy-imports.ban-relative-imports` +/// - `lint.flake8-tidy-imports.ban-relative-imports` /// /// [PEP 8]: https://peps.python.org/pep-0008/#imports #[violation] diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/rules/typing_only_runtime_import.rs b/crates/ruff_linter/src/rules/flake8_type_checking/rules/typing_only_runtime_import.rs index eb933f2c31e9af..42b9f8a2ee05e2 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/rules/typing_only_runtime_import.rs +++ b/crates/ruff_linter/src/rules/flake8_type_checking/rules/typing_only_runtime_import.rs @@ -56,8 +56,8 @@ use crate::rules::isort::{categorize, ImportSection, ImportType}; /// ``` /// /// ## Options -/// - `flake8-type-checking.runtime-evaluated-base-classes` -/// - `flake8-type-checking.runtime-evaluated-decorators` +/// - `lint.flake8-type-checking.runtime-evaluated-base-classes` +/// - `lint.flake8-type-checking.runtime-evaluated-decorators` /// /// ## References /// - [PEP 536](https://peps.python.org/pep-0563/#runtime-annotation-resolution-and-type-checking) @@ -124,8 +124,8 @@ impl Violation for TypingOnlyFirstPartyImport { /// ``` /// /// ## Options -/// - `flake8-type-checking.runtime-evaluated-base-classes` -/// - `flake8-type-checking.runtime-evaluated-decorators` +/// - `lint.flake8-type-checking.runtime-evaluated-base-classes` +/// - `lint.flake8-type-checking.runtime-evaluated-decorators` /// /// ## References /// - [PEP 536](https://peps.python.org/pep-0563/#runtime-annotation-resolution-and-type-checking) @@ -192,8 +192,8 @@ impl Violation for TypingOnlyThirdPartyImport { /// ``` /// /// ## Options -/// - `flake8-type-checking.runtime-evaluated-base-classes` -/// - `flake8-type-checking.runtime-evaluated-decorators` +/// - `lint.flake8-type-checking.runtime-evaluated-base-classes` +/// - `lint.flake8-type-checking.runtime-evaluated-decorators` /// /// ## References /// - [PEP 536](https://peps.python.org/pep-0563/#runtime-annotation-resolution-and-type-checking) diff --git a/crates/ruff_linter/src/rules/mccabe/rules/function_is_too_complex.rs b/crates/ruff_linter/src/rules/mccabe/rules/function_is_too_complex.rs index c56ae7e2ed4aba..165c7ada10a784 100644 --- a/crates/ruff_linter/src/rules/mccabe/rules/function_is_too_complex.rs +++ b/crates/ruff_linter/src/rules/mccabe/rules/function_is_too_complex.rs @@ -44,7 +44,7 @@ use ruff_python_ast::identifier::Identifier; /// ``` /// /// ## Options -/// - `mccabe.max-complexity` +/// - `lint.mccabe.max-complexity` #[violation] pub struct ComplexStructure { name: String, diff --git a/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_first_argument_name_for_class_method.rs b/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_first_argument_name_for_class_method.rs index ff0846786d5eee..f09e0b499acffd 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_first_argument_name_for_class_method.rs +++ b/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_first_argument_name_for_class_method.rs @@ -39,9 +39,9 @@ use crate::checkers::ast::Checker; /// ``` /// /// ## Options -/// - `pep8-naming.classmethod-decorators` -/// - `pep8-naming.staticmethod-decorators` -/// - `pep8-naming.ignore-names` +/// - `lint.pep8-naming.classmethod-decorators` +/// - `lint.pep8-naming.staticmethod-decorators` +/// - `lint.pep8-naming.ignore-names` /// /// [PEP 8]: https://peps.python.org/pep-0008/#function-and-method-arguments #[violation] diff --git a/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_first_argument_name_for_method.rs b/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_first_argument_name_for_method.rs index 4e18781e624e66..a691b90c96f34d 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_first_argument_name_for_method.rs +++ b/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_first_argument_name_for_method.rs @@ -37,9 +37,9 @@ use crate::checkers::ast::Checker; /// ``` /// /// ## Options -/// - `pep8-naming.classmethod-decorators` -/// - `pep8-naming.staticmethod-decorators` -/// - `pep8-naming.ignore-names` +/// - `lint.pep8-naming.classmethod-decorators` +/// - `lint.pep8-naming.staticmethod-decorators` +/// - `lint.pep8-naming.ignore-names` /// /// [PEP 8]: https://peps.python.org/pep-0008/#function-and-method-arguments #[violation] diff --git a/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_function_name.rs b/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_function_name.rs index 468b29dc7a2c4f..4e8b429e21a8f5 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_function_name.rs +++ b/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_function_name.rs @@ -33,7 +33,7 @@ use crate::settings::types::IdentifierPattern; /// ``` /// /// ## Options -/// - `pep8-naming.ignore-names` +/// - `lint.pep8-naming.ignore-names` /// /// [PEP 8]: https://peps.python.org/pep-0008/#function-and-variable-names #[violation] diff --git a/crates/ruff_linter/src/rules/pep8_naming/rules/non_lowercase_variable_in_function.rs b/crates/ruff_linter/src/rules/pep8_naming/rules/non_lowercase_variable_in_function.rs index e8bae1c0eee3c7..d190f9ba859902 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/rules/non_lowercase_variable_in_function.rs +++ b/crates/ruff_linter/src/rules/pep8_naming/rules/non_lowercase_variable_in_function.rs @@ -34,7 +34,7 @@ use crate::rules::pep8_naming::helpers; /// ``` /// /// ## Options -/// - `pep8-naming.ignore-names` +/// - `lint.pep8-naming.ignore-names` /// /// [PEP 8]: https://peps.python.org/pep-0008/#function-and-variable-names #[violation] diff --git a/crates/ruff_linter/src/rules/pycodestyle/rules/doc_line_too_long.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/doc_line_too_long.rs index efa002ab841778..40744ef9e9e46e 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/rules/doc_line_too_long.rs +++ b/crates/ruff_linter/src/rules/pycodestyle/rules/doc_line_too_long.rs @@ -44,9 +44,9 @@ use crate::settings::LinterSettings; /// ``` /// /// ## Options -/// - `task-tags` -/// - `pycodestyle.max-doc-length` -/// - `pycodestyle.ignore-overlong-task-comments` +/// - `lint.task-tags` +/// - `lint.pycodestyle.max-doc-length` +/// - `lint.pycodestyle.ignore-overlong-task-comments` /// /// [PEP 8]: https://peps.python.org/pep-0008/#maximum-line-length #[violation] diff --git a/crates/ruff_linter/src/rules/pycodestyle/rules/line_too_long.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/line_too_long.rs index db18c37f1e6626..16c79ffac2f0b5 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/rules/line_too_long.rs +++ b/crates/ruff_linter/src/rules/pycodestyle/rules/line_too_long.rs @@ -39,8 +39,8 @@ use crate::settings::LinterSettings; /// /// ## Options /// - `line-length` -/// - `task-tags` -/// - `pycodestyle.ignore-overlong-task-comments` +/// - `lint.task-tags` +/// - `lint.pycodestyle.ignore-overlong-task-comments` /// /// [PEP 8]: https://peps.python.org/pep-0008/#maximum-line-length #[violation] diff --git a/crates/ruff_linter/src/rules/pydocstyle/rules/blank_before_after_class.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/blank_before_after_class.rs index 4f74fb736dc2db..fe388f8aaa724c 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/rules/blank_before_after_class.rs +++ b/crates/ruff_linter/src/rules/pydocstyle/rules/blank_before_after_class.rs @@ -37,7 +37,7 @@ use crate::registry::{AsRule, Rule}; /// ``` /// /// ## Options -/// - `pydocstyle.convention` +/// - `lint.pydocstyle.convention` /// /// [D211]: https://docs.astral.sh/ruff/rules/blank-line-before-class #[violation] @@ -84,7 +84,7 @@ impl AlwaysAutofixableViolation for OneBlankLineBeforeClass { /// ``` /// /// ## Options -/// - `pydocstyle.convention` +/// - `lint.pydocstyle.convention` /// /// ## References /// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/) @@ -134,7 +134,7 @@ impl AlwaysAutofixableViolation for OneBlankLineAfterClass { /// ``` /// /// ## Options -/// - `pydocstyle.convention` +/// - `lint.pydocstyle.convention` /// /// [D203]: https://docs.astral.sh/ruff/rules/one-blank-line-before-class #[violation] diff --git a/crates/ruff_linter/src/rules/pydocstyle/rules/ends_with_period.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/ends_with_period.rs index 57c2b63fd0016d..13069e48c12973 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/rules/ends_with_period.rs +++ b/crates/ruff_linter/src/rules/pydocstyle/rules/ends_with_period.rs @@ -36,7 +36,7 @@ use crate::rules::pydocstyle::helpers::logical_line; /// ``` /// /// ## Options -/// - `pydocstyle.convention` +/// - `lint.pydocstyle.convention` /// /// ## References /// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/) diff --git a/crates/ruff_linter/src/rules/pydocstyle/rules/ends_with_punctuation.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/ends_with_punctuation.rs index 05ec17ddb15004..0168a171d1c98c 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/rules/ends_with_punctuation.rs +++ b/crates/ruff_linter/src/rules/pydocstyle/rules/ends_with_punctuation.rs @@ -37,7 +37,7 @@ use crate::rules::pydocstyle::helpers::logical_line; /// ``` /// /// ## Options -/// - `pydocstyle.convention` +/// - `lint.pydocstyle.convention` /// /// ## References /// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/) diff --git a/crates/ruff_linter/src/rules/pydocstyle/rules/no_signature.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/no_signature.rs index b9e186c0929e9f..bbd492cad10d23 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/rules/no_signature.rs +++ b/crates/ruff_linter/src/rules/pydocstyle/rules/no_signature.rs @@ -32,7 +32,7 @@ use crate::docstrings::Docstring; /// ``` /// /// ## Options -/// - `pydocstyle.convention` +/// - `lint.pydocstyle.convention` /// /// ## References /// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/) diff --git a/crates/ruff_linter/src/rules/pydocstyle/rules/non_imperative_mood.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/non_imperative_mood.rs index ca6f210d0abd81..5d779ba1db6d9a 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/rules/non_imperative_mood.rs +++ b/crates/ruff_linter/src/rules/pydocstyle/rules/non_imperative_mood.rs @@ -43,7 +43,7 @@ static MOOD: Lazy = Lazy::new(Mood::new); /// ``` /// /// ## Options -/// - `pydocstyle.convention` +/// - `lint.pydocstyle.convention` /// /// ## References /// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/) diff --git a/crates/ruff_linter/src/rules/pydocstyle/rules/sections.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/sections.rs index 34f78655c89cae..a9f96f1ad9a2d6 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/rules/sections.rs +++ b/crates/ruff_linter/src/rules/pydocstyle/rules/sections.rs @@ -76,7 +76,7 @@ use crate::rules::pydocstyle::settings::Convention; /// ``` /// /// ## Options -/// - `pydocstyle.convention` +/// - `lint.pydocstyle.convention` /// /// ## References /// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/) @@ -175,7 +175,7 @@ impl AlwaysAutofixableViolation for SectionNotOverIndented { /// ``` /// /// ## Options -/// - `pydocstyle.convention` +/// - `lint.pydocstyle.convention` /// /// ## References /// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/) @@ -253,7 +253,7 @@ impl AlwaysAutofixableViolation for SectionUnderlineNotOverIndented { /// ``` /// /// ## Options -/// - `pydocstyle.convention` +/// - `lint.pydocstyle.convention` /// /// ## References /// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/) @@ -350,7 +350,7 @@ impl AlwaysAutofixableViolation for CapitalizeSectionName { /// ``` /// /// ## Options -/// - `pydocstyle.convention` +/// - `lint.pydocstyle.convention` /// /// ## References /// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/) @@ -446,7 +446,7 @@ impl AlwaysAutofixableViolation for NewLineAfterSectionName { /// ``` /// /// ## Options -/// - `pydocstyle.convention` +/// - `lint.pydocstyle.convention` /// /// ## References /// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/) @@ -548,7 +548,7 @@ impl AlwaysAutofixableViolation for DashedUnderlineAfterSection { /// ``` /// /// ## Options -/// - `pydocstyle.convention` +/// - `lint.pydocstyle.convention` /// /// ## References /// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/) @@ -647,7 +647,7 @@ impl AlwaysAutofixableViolation for SectionUnderlineAfterName { /// ``` /// /// ## Options -/// - `pydocstyle.convention` +/// - `lint.pydocstyle.convention` /// /// ## References /// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/) @@ -741,7 +741,7 @@ impl AlwaysAutofixableViolation for SectionUnderlineMatchesSectionLength { /// ``` /// /// ## Options -/// - `pydocstyle.convention` +/// - `lint.pydocstyle.convention` /// /// ## References /// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/) @@ -835,7 +835,7 @@ impl AlwaysAutofixableViolation for NoBlankLineAfterSection { /// ``` /// /// ## Options -/// - `pydocstyle.convention` +/// - `lint.pydocstyle.convention` /// /// ## References /// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/) @@ -931,7 +931,7 @@ impl AlwaysAutofixableViolation for NoBlankLineBeforeSection { /// ``` /// /// ## Options -/// - `pydocstyle.convention` +/// - `lint.pydocstyle.convention` /// /// ## References /// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/) @@ -1021,7 +1021,7 @@ impl AlwaysAutofixableViolation for BlankLineAfterLastSection { /// ``` /// /// ## Options -/// - `pydocstyle.convention` +/// - `lint.pydocstyle.convention` /// /// ## References /// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/) @@ -1098,7 +1098,7 @@ impl Violation for EmptyDocstringSection { /// ``` /// /// ## Options -/// - `pydocstyle.convention` +/// - `lint.pydocstyle.convention` /// /// ## References /// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/) @@ -1180,7 +1180,7 @@ impl AlwaysAutofixableViolation for SectionNameEndsInColon { /// ``` /// /// ## Options -/// - `pydocstyle.convention` +/// - `lint.pydocstyle.convention` /// /// ## References /// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/) @@ -1264,7 +1264,7 @@ impl Violation for UndocumentedParam { /// ``` /// /// ## Options -/// - `pydocstyle.convention` +/// - `lint.pydocstyle.convention` /// /// ## References /// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/) diff --git a/crates/ruff_linter/src/rules/pydocstyle/rules/starts_with_this.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/starts_with_this.rs index 0cd38e1114c3a4..2d9034a2b0991e 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/rules/starts_with_this.rs +++ b/crates/ruff_linter/src/rules/pydocstyle/rules/starts_with_this.rs @@ -33,7 +33,7 @@ use crate::rules::pydocstyle::helpers::normalize_word; /// ``` /// /// ## Options -/// - `pydocstyle.convention` +/// - `lint.pydocstyle.convention` /// /// ## References /// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/) diff --git a/crates/ruff_linter/src/rules/pyflakes/rules/unused_import.rs b/crates/ruff_linter/src/rules/pyflakes/rules/unused_import.rs index d9899a483f1cd7..85ffe2f4282dcc 100644 --- a/crates/ruff_linter/src/rules/pyflakes/rules/unused_import.rs +++ b/crates/ruff_linter/src/rules/pyflakes/rules/unused_import.rs @@ -54,7 +54,7 @@ enum UnusedImportContext { /// ``` /// /// ## Options -/// - `pyflakes.extend-generics` +/// - `lint.pyflakes.extend-generics` /// /// ## References /// - [Python documentation: `import`](https://docs.python.org/3/reference/simple_stmts.html#the-import-statement) diff --git a/crates/ruff_linter/src/rules/pyflakes/rules/unused_variable.rs b/crates/ruff_linter/src/rules/pyflakes/rules/unused_variable.rs index 64aaa16e757dcb..d151259e35025b 100644 --- a/crates/ruff_linter/src/rules/pyflakes/rules/unused_variable.rs +++ b/crates/ruff_linter/src/rules/pyflakes/rules/unused_variable.rs @@ -41,7 +41,7 @@ use crate::registry::AsRule; /// ``` /// /// ## Options -/// - `dummy-variable-rgx` +/// - `lint.dummy-variable-rgx` #[violation] pub struct UnusedVariable { pub name: String, diff --git a/crates/ruff_linter/src/rules/pylint/rules/too_many_arguments.rs b/crates/ruff_linter/src/rules/pylint/rules/too_many_arguments.rs index 8948aeb0cc1526..44af3c77367cf6 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/too_many_arguments.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/too_many_arguments.rs @@ -42,7 +42,7 @@ use crate::checkers::ast::Checker; /// ``` /// /// ## Options -/// - `pylint.max-args` +/// - `lint.pylint.max-args` #[violation] pub struct TooManyArguments { c_args: usize, diff --git a/crates/ruff_linter/src/rules/pylint/rules/too_many_branches.rs b/crates/ruff_linter/src/rules/pylint/rules/too_many_branches.rs index 7c083b10f76548..a62fc93c6b9964 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/too_many_branches.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/too_many_branches.rs @@ -67,7 +67,7 @@ use ruff_python_ast::identifier::Identifier; /// ``` /// /// ## Options -/// - `pylint.max-branches` +/// - `lint.pylint.max-branches` #[violation] pub struct TooManyBranches { branches: usize, diff --git a/crates/ruff_linter/src/rules/pylint/rules/too_many_public_methods.rs b/crates/ruff_linter/src/rules/pylint/rules/too_many_public_methods.rs index 7e7c113d80ad44..9caa94f4624d4e 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/too_many_public_methods.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/too_many_public_methods.rs @@ -81,7 +81,7 @@ use crate::checkers::ast::Checker; /// ``` /// /// ## Options -/// - `pylint.max-public-methods` +/// - `lint.pylint.max-public-methods` #[violation] pub struct TooManyPublicMethods { methods: usize, diff --git a/crates/ruff_linter/src/rules/pylint/rules/too_many_return_statements.rs b/crates/ruff_linter/src/rules/pylint/rules/too_many_return_statements.rs index 8fc7fe16e61341..fc776a75a9115a 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/too_many_return_statements.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/too_many_return_statements.rs @@ -50,7 +50,7 @@ use ruff_python_ast::statement_visitor::StatementVisitor; /// ``` /// /// ## Options -/// - `pylint.max-returns` +/// - `lint.pylint.max-returns` #[violation] pub struct TooManyReturnStatements { returns: usize, diff --git a/crates/ruff_linter/src/rules/pylint/rules/too_many_statements.rs b/crates/ruff_linter/src/rules/pylint/rules/too_many_statements.rs index 406f5959fc33ae..9e313980addae9 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/too_many_statements.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/too_many_statements.rs @@ -44,7 +44,7 @@ use ruff_python_ast::identifier::Identifier; /// ``` /// /// ## Options -/// - `pylint.max-statements` +/// - `lint.pylint.max-statements` #[violation] pub struct TooManyStatements { statements: usize, diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/use_pep585_annotation.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/use_pep585_annotation.rs index aaeef4bba0ffb5..5c12f5a09da82c 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/use_pep585_annotation.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/use_pep585_annotation.rs @@ -46,7 +46,7 @@ use crate::registry::AsRule; /// /// ## Options /// - `target-version` -/// - `pyupgrade.keep-runtime-typing` +/// - `lint.pyupgrade.keep-runtime-typing` /// /// [PEP 585]: https://peps.python.org/pep-0585/ #[violation] diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/use_pep604_annotation.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/use_pep604_annotation.rs index c1fbbfa6cec22e..8e9111d799049f 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/use_pep604_annotation.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/use_pep604_annotation.rs @@ -38,7 +38,7 @@ use crate::registry::AsRule; /// /// ## Options /// - `target-version` -/// - `pyupgrade.keep-runtime-typing` +/// - `lint.pyupgrade.keep-runtime-typing` /// /// [PEP 604]: https://peps.python.org/pep-0604/ #[violation] diff --git a/crates/ruff_linter/src/rules/ruff/rules/function_call_in_dataclass_default.rs b/crates/ruff_linter/src/rules/ruff/rules/function_call_in_dataclass_default.rs index f8d5af0672698b..5e23bcb9ab3681 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/function_call_in_dataclass_default.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/function_call_in_dataclass_default.rs @@ -53,7 +53,7 @@ use crate::rules::ruff::rules::helpers::{ /// ``` /// /// ## Options -/// - `flake8-bugbear.extend-immutable-calls` +/// - `lint.flake8-bugbear.extend-immutable-calls` #[violation] pub struct FunctionCallInDataclassDefaultArgument { name: Option, diff --git a/crates/ruff_wasm/src/lib.rs b/crates/ruff_wasm/src/lib.rs index e30407af5aab44..580f24363f9e18 100644 --- a/crates/ruff_wasm/src/lib.rs +++ b/crates/ruff_wasm/src/lib.rs @@ -6,11 +6,9 @@ use wasm_bindgen::prelude::*; use ruff_formatter::{FormatResult, Formatted}; use ruff_linter::directives; -use ruff_linter::line_width::{LineLength, TabSize}; use ruff_linter::linter::{check_path, LinterResult}; use ruff_linter::registry::AsRule; -use ruff_linter::settings::types::PythonVersion; -use ruff_linter::settings::{flags, DUMMY_VARIABLE_RGX, PREFIXES}; +use ruff_linter::settings::flags; use ruff_linter::source_kind::SourceKind; use ruff_python_ast::{Mod, PySourceType}; use ruff_python_codegen::Stylist; @@ -22,7 +20,7 @@ use ruff_python_trivia::CommentRanges; use ruff_source_file::{Locator, SourceLocation}; use ruff_text_size::Ranged; use ruff_workspace::configuration::Configuration; -use ruff_workspace::options::Options; +use ruff_workspace::options::{LintOptions, Options}; use ruff_workspace::Settings; #[wasm_bindgen(typescript_custom_section)] @@ -119,46 +117,34 @@ impl Workspace { #[wasm_bindgen(js_name = defaultSettings)] pub fn default_settings() -> Result { serde_wasm_bindgen::to_value(&Options { - // Propagate defaults. - allowed_confusables: Some(Vec::default()), - builtins: Some(Vec::default()), - dummy_variable_rgx: Some(DUMMY_VARIABLE_RGX.as_str().to_string()), - extend_fixable: Some(Vec::default()), - extend_ignore: Some(Vec::default()), - extend_select: Some(Vec::default()), - extend_unfixable: Some(Vec::default()), - external: Some(Vec::default()), - ignore: Some(Vec::default()), - line_length: Some(LineLength::default()), - preview: Some(false), - select: Some(PREFIXES.to_vec()), - tab_size: Some(TabSize::default()), - target_version: Some(PythonVersion::default()), // Ignore a bunch of options that don't make sense in a single-file editor. cache_dir: None, exclude: None, extend: None, extend_exclude: None, extend_include: None, - extend_per_file_ignores: None, fix: None, fix_only: None, - fixable: None, + lint: Some(LintOptions { + extend_per_file_ignores: None, + fixable: None, + logger_objects: None, + per_file_ignores: None, + task_tags: None, + unfixable: None, + ignore_init_module_imports: None, + ..LintOptions::default() + }), force_exclude: None, output_format: None, - ignore_init_module_imports: None, include: None, - logger_objects: None, namespace_packages: None, - per_file_ignores: None, required_version: None, respect_gitignore: None, show_fixes: None, show_source: None, src: None, - task_tags: None, typing_modules: None, - unfixable: None, ..Options::default() }) .map_err(into_error) diff --git a/crates/ruff_workspace/src/configuration.rs b/crates/ruff_workspace/src/configuration.rs index a30972f18952ed..8e6cc7e43af532 100644 --- a/crates/ruff_workspace/src/configuration.rs +++ b/crates/ruff_workspace/src/configuration.rs @@ -39,8 +39,9 @@ use crate::options::{ Flake8ComprehensionsOptions, Flake8CopyrightOptions, Flake8ErrMsgOptions, Flake8GetTextOptions, Flake8ImplicitStrConcatOptions, Flake8ImportConventionsOptions, Flake8PytestStyleOptions, Flake8QuotesOptions, Flake8SelfOptions, Flake8TidyImportsOptions, Flake8TypeCheckingOptions, - Flake8UnusedArgumentsOptions, IsortOptions, McCabeOptions, Options, Pep8NamingOptions, - PyUpgradeOptions, PycodestyleOptions, PydocstyleOptions, PyflakesOptions, PylintOptions, + Flake8UnusedArgumentsOptions, IsortOptions, LintOptions, McCabeOptions, Options, + Pep8NamingOptions, PyUpgradeOptions, PycodestyleOptions, PydocstyleOptions, PyflakesOptions, + PylintOptions, }; use crate::settings::{FileResolverSettings, Settings, EXCLUDE, INCLUDE}; @@ -65,13 +66,14 @@ pub struct Configuration { pub show_source: Option, pub required_version: Option, pub preview: Option, + pub extend: Option, // File resolver options pub exclude: Option>, - pub extend: Option, pub extend_exclude: Vec, pub extend_include: Vec, pub force_exclude: Option, + pub include: Option>, pub respect_gitignore: Option, // Generic python options settings @@ -123,7 +125,7 @@ impl Configuration { extend_include: FilePatternSet::try_from_iter(self.extend_include)?, force_exclude: self.force_exclude.unwrap_or(false), include: FilePatternSet::try_from_iter( - self.lint.include.unwrap_or_else(|| INCLUDE.to_vec()), + self.include.unwrap_or_else(|| INCLUDE.to_vec()), )?, respect_gitignore: self.respect_gitignore.unwrap_or(true), project_root: project_root.to_path_buf(), @@ -313,6 +315,13 @@ impl Configuration { } pub fn from_options(options: Options, project_root: &Path) -> Result { + // TODO warn about legacy options + let lint = if let Some(lint) = options.lint { + lint.combine(options.lint_legacy) + } else { + options.lint_legacy + }; + Ok(Self { builtins: options.builtins, cache_dir: options @@ -365,7 +374,15 @@ impl Configuration { .collect() }) .unwrap_or_default(), - + include: options.include.map(|paths| { + paths + .into_iter() + .map(|pattern| { + let absolute = fs::normalize_path_to(&pattern, project_root); + FilePattern::User(pattern, absolute) + }) + .collect() + }), fix: options.fix, fix_only: options.fix_only, output_format: options.output_format.or(options.format), @@ -388,89 +405,7 @@ impl Configuration { target_version: options.target_version, typing_modules: options.typing_modules, - lint: LintConfiguration { - rule_selections: vec![RuleSelection { - select: options.select, - ignore: options - .ignore - .into_iter() - .flatten() - .chain(options.extend_ignore.into_iter().flatten()) - .collect(), - extend_select: options.extend_select.unwrap_or_default(), - fixable: options.fixable, - unfixable: options - .unfixable - .into_iter() - .flatten() - .chain(options.extend_unfixable.into_iter().flatten()) - .collect(), - extend_fixable: options.extend_fixable.unwrap_or_default(), - }], - allowed_confusables: options.allowed_confusables, - dummy_variable_rgx: options - .dummy_variable_rgx - .map(|pattern| Regex::new(&pattern)) - .transpose() - .map_err(|e| anyhow!("Invalid `dummy-variable-rgx` value: {e}"))?, - extend_per_file_ignores: options - .extend_per_file_ignores - .map(|per_file_ignores| { - per_file_ignores - .into_iter() - .map(|(pattern, prefixes)| { - PerFileIgnore::new(pattern, &prefixes, Some(project_root)) - }) - .collect() - }) - .unwrap_or_default(), - external: options.external, - ignore_init_module_imports: options.ignore_init_module_imports, - include: options.include.map(|paths| { - paths - .into_iter() - .map(|pattern| { - let absolute = fs::normalize_path_to(&pattern, project_root); - FilePattern::User(pattern, absolute) - }) - .collect() - }), - per_file_ignores: options.per_file_ignores.map(|per_file_ignores| { - per_file_ignores - .into_iter() - .map(|(pattern, prefixes)| { - PerFileIgnore::new(pattern, &prefixes, Some(project_root)) - }) - .collect() - }), - task_tags: options.task_tags, - logger_objects: options.logger_objects, - // Plugins - flake8_annotations: options.flake8_annotations, - flake8_bandit: options.flake8_bandit, - 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, - }, + lint: LintConfiguration::from_options(lint, project_root)?, }) } @@ -491,6 +426,7 @@ impl Configuration { .into_iter() .chain(self.extend_include) .collect(), + include: self.include.or(config.include), fix: self.fix.or(config.fix), fix_only: self.fix_only.or(config.fix_only), output_format: self.output_format.or(config.output_format), @@ -523,7 +459,6 @@ pub struct LintConfiguration { pub allowed_confusables: Option>, pub external: Option>, pub ignore_init_module_imports: Option, - pub include: Option>, pub logger_objects: Option>, pub task_tags: Option>, @@ -555,6 +490,83 @@ pub struct LintConfiguration { } impl LintConfiguration { + fn from_options(options: LintOptions, project_root: &Path) -> Result { + Ok(LintConfiguration { + rule_selections: vec![RuleSelection { + select: options.select, + ignore: options + .ignore + .into_iter() + .flatten() + .chain(options.extend_ignore.into_iter().flatten()) + .collect(), + extend_select: options.extend_select.unwrap_or_default(), + fixable: options.fixable, + unfixable: options + .unfixable + .into_iter() + .flatten() + .chain(options.extend_unfixable.into_iter().flatten()) + .collect(), + extend_fixable: options.extend_fixable.unwrap_or_default(), + }], + allowed_confusables: options.allowed_confusables, + dummy_variable_rgx: options + .dummy_variable_rgx + .map(|pattern| Regex::new(&pattern)) + .transpose() + .map_err(|e| anyhow!("Invalid `dummy-variable-rgx` value: {e}"))?, + extend_per_file_ignores: options + .extend_per_file_ignores + .map(|per_file_ignores| { + per_file_ignores + .into_iter() + .map(|(pattern, prefixes)| { + PerFileIgnore::new(pattern, &prefixes, Some(project_root)) + }) + .collect() + }) + .unwrap_or_default(), + external: options.external, + ignore_init_module_imports: options.ignore_init_module_imports, + per_file_ignores: options.per_file_ignores.map(|per_file_ignores| { + per_file_ignores + .into_iter() + .map(|(pattern, prefixes)| { + PerFileIgnore::new(pattern, &prefixes, Some(project_root)) + }) + .collect() + }), + task_tags: options.task_tags, + logger_objects: options.logger_objects, + // Plugins + flake8_annotations: options.flake8_annotations, + flake8_bandit: options.flake8_bandit, + 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, + }) + } + fn as_rule_table(&self, preview: PreviewMode) -> RuleTable { // The select_set keeps track of which rules have been selected. let mut select_set: RuleSet = PREFIXES @@ -802,7 +814,6 @@ impl LintConfiguration { .chain(self.extend_per_file_ignores) .collect(), external: self.external.or(config.external), - include: self.include.or(config.include), ignore_init_module_imports: self .ignore_init_module_imports .or(config.ignore_init_module_imports), diff --git a/crates/ruff_workspace/src/options.rs b/crates/ruff_workspace/src/options.rs index d5b8ea28f024e7..7bd99c15a68895 100644 --- a/crates/ruff_workspace/src/options.rs +++ b/crates/ruff_workspace/src/options.rs @@ -29,30 +29,6 @@ use strum::IntoEnumIterator; #[serde(deny_unknown_fields, rename_all = "kebab-case")] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub struct Options { - /// A list of allowed "confusable" Unicode characters to ignore when - /// enforcing `RUF001`, `RUF002`, and `RUF003`. - #[option( - default = r#"[]"#, - value_type = "list[str]", - example = r#" - # Allow minus-sign (U+2212), greek-small-letter-rho (U+03C1), and the asterisk-operator (U+2217), - # which could be confused for "-", "p", and "*", respectively. - allowed-confusables = ["−", "ρ", "∗"] - "# - )] - pub allowed_confusables: Option>, - - /// A list of builtins to treat as defined references, in addition to the - /// system builtins. - #[option( - default = r#"[]"#, - value_type = "list[str]", - example = r#" - builtins = ["_"] - "# - )] - pub builtins: Option>, - /// A path to the cache directory. /// /// By default, Ruff stores cache results in a `.ruff_cache` directory in @@ -70,19 +46,109 @@ pub struct Options { )] pub cache_dir: Option, - /// 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_`. + /// A path to a local `pyproject.toml` file to merge into this + /// configuration. User home directory and environment variables will be + /// expanded. + /// + /// To 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. #[option( - default = r#""^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$""#, - value_type = "re.Pattern", + default = r#"None"#, + value_type = "str", example = r#" - # Only ignore variables named "_". - dummy-variable-rgx = "^_$" + # Extend the `pyproject.toml` file in the parent directory. + extend = "../pyproject.toml" + # But use a different line length. + line-length = 100 "# )] - pub dummy_variable_rgx: Option, + pub extend: Option, + + /// The style in which violation messages should be formatted: `"text"` + /// (default), `"grouped"` (group messages by file), `"json"` + /// (machine-readable), `"junit"` (machine-readable XML), `"github"` (GitHub + /// Actions annotations), `"gitlab"` (GitLab CI code quality report), + /// `"pylint"` (Pylint text format) or `"azure"` (Azure Pipeline logging commands). + /// + /// This option has been **deprecated** in favor of `output-format` + /// to avoid ambiguity with Ruff's upcoming formatter. + #[cfg_attr(feature = "schemars", schemars(skip))] + pub format: Option, + /// The style in which violation messages should be formatted: `"text"` + /// (default), `"grouped"` (group messages by file), `"json"` + /// (machine-readable), `"junit"` (machine-readable XML), `"github"` (GitHub + /// Actions annotations), `"gitlab"` (GitLab CI code quality report), + /// `"pylint"` (Pylint text format) or `"azure"` (Azure Pipeline logging commands). + #[option( + default = r#""text""#, + value_type = r#""text" | "json" | "junit" | "github" | "gitlab" | "pylint" | "azure""#, + example = r#" + # Group violations by containing file. + output-format = "grouped" + "# + )] + pub output_format: Option, + + /// Enable autofix behavior by-default when running `ruff` (overridden + /// by the `--fix` and `--no-fix` command-line flags). + #[option(default = "false", value_type = "bool", example = "fix = true")] + pub fix: Option, + + /// Like `fix`, but disables reporting on leftover violation. Implies `fix`. + #[option(default = "false", value_type = "bool", example = "fix-only = true")] + pub fix_only: Option, + + /// Whether to show source code snippets when reporting lint violations + /// (overridden by the `--show-source` command-line flag). + #[option( + default = "false", + value_type = "bool", + example = r#" + # By default, always show source code snippets. + show-source = true + "# + )] + pub show_source: Option, + + /// Whether to show an enumeration of all autofixed lint violations + /// (overridden by the `--show-fixes` command-line flag). + #[option( + default = "false", + value_type = "bool", + example = r#" + # Enumerate all fixed violations. + show-fixes = true + "# + )] + pub show_fixes: Option, + + /// Require a specific version of Ruff to be running (useful for unifying + /// results across many environments, e.g., with a `pyproject.toml` + /// file). + #[option( + default = "None", + value_type = "str", + example = r#" + required-version = "0.0.193" + "# + )] + pub required_version: Option, + + /// Whether to enable preview mode. When preview mode is enabled, Ruff will + /// use unstable rules and fixes. + #[option( + default = "false", + value_type = "bool", + example = r#" + # Enable preview features + preview = true + "# + )] + pub preview: Option, + + // File resolver options /// A list of file patterns to exclude from linting. /// /// Exclusions are based on globs, and can be either: @@ -108,25 +174,6 @@ pub struct Options { )] pub exclude: Option>, - /// A path to a local `pyproject.toml` file to merge into this - /// configuration. User home directory and environment variables will be - /// expanded. - /// - /// To 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. - #[option( - default = r#"None"#, - value_type = "str", - example = r#" - # Extend the `pyproject.toml` file in the parent directory. - extend = "../pyproject.toml" - # But use a different line length. - line-length = 100 - "# - )] - pub extend: Option, - /// A list of file patterns to omit from linting, in addition to those /// specified by `exclude`. /// @@ -162,11 +209,230 @@ pub struct Options { default = "[]", value_type = "list[str]", example = r#" - # In addition to the standard set of inclusions, include `.pyw` files. - extend-include = ["*.pyw"] + # In addition to the standard set of inclusions, include `.pyw` files. + extend-include = ["*.pyw"] + "# + )] + pub extend_include: Option>, + + #[option( + default = r#"false"#, + value_type = "bool", + example = r#" + force-exclude = true + "# + )] + /// 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. + /// + /// This 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. + #[option( + default = r#"false"#, + value_type = "bool", + example = r#" + force-exclude = true + "# + )] + pub force_exclude: Option, + + /// A list of file patterns to include when linting. + /// + /// Inclusion 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. + /// + /// For more information on the glob syntax, refer to the [`globset` documentation](https://docs.rs/globset/latest/globset/#syntax). + #[option( + default = r#"["*.py", "*.pyi", "**/pyproject.toml"]"#, + value_type = "list[str]", + example = r#" + include = ["*.py"] + "# + )] + pub include: Option>, + + /// Whether to automatically exclude files that are ignored by `.ignore`, + /// `.gitignore`, `.git/info/exclude`, and global `gitignore` files. + /// Enabled by default. + #[option( + default = "true", + value_type = "bool", + example = r#" + respect-gitignore = false + "# + )] + pub respect_gitignore: Option, + + // Generic python options + /// A list of builtins to treat as defined references, in addition to the + /// system builtins. + #[option( + default = r#"[]"#, + value_type = "list[str]", + example = r#" + builtins = ["_"] + "# + )] + pub builtins: Option>, + + /// Mark the specified directories as namespace packages. For the purpose of + /// module resolution, Ruff will treat those directories as if they + /// contained an `__init__.py` file. + #[option( + default = r#"[]"#, + value_type = "list[str]", + example = r#" + namespace-packages = ["airflow/providers"] + "# + )] + pub namespace_packages: Option>, + + /// 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. + /// + /// For example, to represent supporting Python >=3.10 or ==3.10 + /// specify `target-version = "py310"`. + /// + /// If omitted, and Ruff is configured via a `pyproject.toml` file, the + /// target version will be inferred from its `project.requires-python` + /// field (e.g., `requires-python = ">=3.8"`). If Ruff is configured via + /// `ruff.toml` or `.ruff.toml`, no such inference will be performed. + #[option( + default = r#""py38""#, + value_type = r#""py37" | "py38" | "py39" | "py310" | "py311" | "py312""#, + example = r#" + # Always generate Python 3.7-compatible code. + target-version = "py37" + "# + )] + pub target_version: Option, + + /// The directories to consider when resolving first- vs. third-party + /// imports. + /// + /// As an example: given a Python package structure like: + /// + /// ```text + /// my_project + /// ├── pyproject.toml + /// └── src + /// └── my_package + /// ├── __init__.py + /// ├── foo.py + /// └── bar.py + /// ``` + /// + /// The `./src` directory should be included in the `src` option + /// (e.g., `src = ["src"]`), such that when resolving imports, + /// `my_package.foo` is considered a first-party import. + /// + /// When omitted, the `src` directory will typically default to the + /// directory containing the nearest `pyproject.toml`, `ruff.toml`, or + /// `.ruff.toml` file (the "project root"), unless a configuration file + /// is explicitly provided (e.g., via the `--config` command-line flag). + /// + /// This field supports globs. For example, if you have a series of Python + /// packages in a `python_modules` directory, `src = ["python_modules/*"]` + /// would expand to incorporate all of the packages in that directory. User + /// home directory and environment variables will also be expanded. + #[option( + default = r#"["."]"#, + value_type = "list[str]", + example = r#" + # Allow imports relative to the "src" and "test" directories. + src = ["src", "test"] + "# + )] + pub src: Option>, + + /// A list of modules whose exports should be treated equivalently to + /// members of the `typing` module. + /// + /// This 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. + #[option( + default = r#"[]"#, + value_type = "list[str]", + example = r#"typing-modules = ["airflow.typing_compat"]"# + )] + pub typing_modules: Option>, + + // Global Formatting options + /// The line length to use when enforcing long-lines violations (like + /// `E501`). Must be greater than `0` and less than or equal to `320`. + #[option( + default = "88", + value_type = "int", + example = r#" + # Allow lines to be as long as 120 characters. + line-length = 120 + "# + )] + #[cfg_attr(feature = "schemars", schemars(range(min = 1, max = 320)))] + pub line_length: Option, + + /// The tabulation size to calculate line length. + #[option( + default = "4", + value_type = "int", + example = r#" + tab-size = 8 + "# + )] + pub tab_size: Option, + + // Lint options + /// Options for the Ruff linter + #[option_group] + pub lint: Option, + + /// Doc + #[serde(flatten)] + pub lint_legacy: LintOptions, +} + +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +#[derive( + Debug, PartialEq, Eq, Default, ConfigurationOptions, CombineOptions, Serialize, Deserialize, +)] +#[serde(deny_unknown_fields, rename_all = "kebab-case")] +pub struct LintOptions { + /// A list of allowed "confusable" Unicode characters to ignore when + /// enforcing `RUF001`, `RUF002`, and `RUF003`. + #[option( + default = r#"[]"#, + value_type = "list[str]", + example = r#" + # Allow minus-sign (U+2212), greek-small-letter-rho (U+03C1), and the asterisk-operator (U+2217), + # which could be confused for "-", "p", and "*", respectively. + allowed-confusables = ["−", "ρ", "∗"] + "# + )] + pub allowed_confusables: Option>, + + /// 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_`. + #[option( + default = r#""^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$""#, + value_type = "re.Pattern", + example = r#" + # Only ignore variables named "_". + dummy-variable-rgx = "^_$" "# )] - pub extend_include: Option>, + pub dummy_variable_rgx: Option, /// A list of rule codes or prefixes to ignore, in addition to those /// specified by `ignore`. @@ -231,15 +497,6 @@ pub struct Options { )] pub external: Option>, - /// Enable autofix behavior by-default when running `ruff` (overridden - /// by the `--fix` and `--no-fix` command-line flags). - #[option(default = "false", value_type = "bool", example = "fix = true")] - pub fix: Option, - - /// Like `fix`, but disables reporting on leftover violation. Implies `fix`. - #[option(default = "false", value_type = "bool", example = "fix-only = true")] - pub fix_only: Option, - /// A list of rule codes or prefixes to consider autofixable. By default, /// all rules are considered autofixable. #[option( @@ -252,58 +509,6 @@ pub struct Options { )] pub fixable: Option>, - /// The style in which violation messages should be formatted: `"text"` - /// (default), `"grouped"` (group messages by file), `"json"` - /// (machine-readable), `"junit"` (machine-readable XML), `"github"` (GitHub - /// Actions annotations), `"gitlab"` (GitLab CI code quality report), - /// `"pylint"` (Pylint text format) or `"azure"` (Azure Pipeline logging commands). - /// - /// This option has been **deprecated** in favor of `output-format` - /// to avoid ambiguity with Ruff's upcoming formatter. - #[cfg_attr(feature = "schemars", schemars(skip))] - pub format: Option, - - /// The style in which violation messages should be formatted: `"text"` - /// (default), `"grouped"` (group messages by file), `"json"` - /// (machine-readable), `"junit"` (machine-readable XML), `"github"` (GitHub - /// Actions annotations), `"gitlab"` (GitLab CI code quality report), - /// `"pylint"` (Pylint text format) or `"azure"` (Azure Pipeline logging commands). - #[option( - default = r#""text""#, - value_type = r#""text" | "json" | "junit" | "github" | "gitlab" | "pylint" | "azure""#, - example = r#" - # Group violations by containing file. - output-format = "grouped" - "# - )] - pub output_format: Option, - - #[option( - default = r#"false"#, - value_type = "bool", - example = r#" - force-exclude = true - "# - )] - /// 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. - /// - /// This 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. - #[option( - default = r#"false"#, - value_type = "bool", - example = r#" - force-exclude = true - "# - )] - pub force_exclude: Option, - /// A list of rule codes or prefixes to ignore. Prefixes can specify exact /// rules (like `F841`), entire categories (like `F`), or anything in /// between. @@ -334,46 +539,6 @@ pub struct Options { )] pub ignore_init_module_imports: Option, - /// A list of file patterns to include when linting. - /// - /// Inclusion 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. - /// - /// For more information on the glob syntax, refer to the [`globset` documentation](https://docs.rs/globset/latest/globset/#syntax). - #[option( - default = r#"["*.py", "*.pyi", "**/pyproject.toml"]"#, - value_type = "list[str]", - example = r#" - include = ["*.py"] - "# - )] - pub include: Option>, - - /// The line length to use when enforcing long-lines violations (like - /// `E501`). Must be greater than `0` and less than or equal to `320`. - #[option( - default = "88", - value_type = "int", - example = r#" - # Allow lines to be as long as 120 characters. - line-length = 120 - "# - )] - #[cfg_attr(feature = "schemars", schemars(range(min = 1, max = 320)))] - pub line_length: Option, - - /// The tabulation size to calculate line length. - #[option( - default = "4", - value_type = "int", - example = r#" - tab-size = 8 - "# - )] - pub tab_size: Option, - /// A list of objects that should be treated equivalently to a /// `logging.Logger` object. /// @@ -399,30 +564,6 @@ pub struct Options { )] pub logger_objects: Option>, - /// Require a specific version of Ruff to be running (useful for unifying - /// results across many environments, e.g., with a `pyproject.toml` - /// file). - #[option( - default = "None", - value_type = "str", - example = r#" - required-version = "0.0.193" - "# - )] - pub required_version: Option, - - /// Whether to automatically exclude files that are ignored by `.ignore`, - /// `.gitignore`, `.git/info/exclude`, and global `gitignore` files. - /// Enabled by default. - #[option( - default = "true", - value_type = "bool", - example = r#" - respect-gitignore = false - "# - )] - pub respect_gitignore: Option, - /// A list of rule codes or prefixes to enable. Prefixes can specify exact /// rules (like `F841`), entire categories (like `F`), or anything in /// between. @@ -440,113 +581,6 @@ pub struct Options { )] pub select: Option>, - /// Whether to show source code snippets when reporting lint violations - /// (overridden by the `--show-source` command-line flag). - #[option( - default = "false", - value_type = "bool", - example = r#" - # By default, always show source code snippets. - show-source = true - "# - )] - pub show_source: Option, - - /// Whether to show an enumeration of all autofixed lint violations - /// (overridden by the `--show-fixes` command-line flag). - #[option( - default = "false", - value_type = "bool", - example = r#" - # Enumerate all fixed violations. - show-fixes = true - "# - )] - pub show_fixes: Option, - - /// The directories to consider when resolving first- vs. third-party - /// imports. - /// - /// As an example: given a Python package structure like: - /// - /// ```text - /// my_project - /// ├── pyproject.toml - /// └── src - /// └── my_package - /// ├── __init__.py - /// ├── foo.py - /// └── bar.py - /// ``` - /// - /// The `./src` directory should be included in the `src` option - /// (e.g., `src = ["src"]`), such that when resolving imports, - /// `my_package.foo` is considered a first-party import. - /// - /// When omitted, the `src` directory will typically default to the - /// directory containing the nearest `pyproject.toml`, `ruff.toml`, or - /// `.ruff.toml` file (the "project root"), unless a configuration file - /// is explicitly provided (e.g., via the `--config` command-line flag). - /// - /// This field supports globs. For example, if you have a series of Python - /// packages in a `python_modules` directory, `src = ["python_modules/*"]` - /// would expand to incorporate all of the packages in that directory. User - /// home directory and environment variables will also be expanded. - #[option( - default = r#"["."]"#, - value_type = "list[str]", - example = r#" - # Allow imports relative to the "src" and "test" directories. - src = ["src", "test"] - "# - )] - pub src: Option>, - - /// Mark the specified directories as namespace packages. For the purpose of - /// module resolution, Ruff will treat those directories as if they - /// contained an `__init__.py` file. - #[option( - default = r#"[]"#, - value_type = "list[str]", - example = r#" - namespace-packages = ["airflow/providers"] - "# - )] - pub namespace_packages: Option>, - - /// 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. - /// - /// For example, to represent supporting Python >=3.10 or ==3.10 - /// specify `target-version = "py310"`. - /// - /// If omitted, and Ruff is configured via a `pyproject.toml` file, the - /// target version will be inferred from its `project.requires-python` - /// field (e.g., `requires-python = ">=3.8"`). If Ruff is configured via - /// `ruff.toml` or `.ruff.toml`, no such inference will be performed. - #[option( - default = r#""py38""#, - value_type = r#""py37" | "py38" | "py39" | "py310" | "py311" | "py312""#, - example = r#" - # Always generate Python 3.7-compatible code. - target-version = "py37" - "# - )] - pub target_version: Option, - - /// Whether to enable preview mode. When preview mode is enabled, Ruff will - /// use unstable rules and fixes. - #[option( - default = "false", - value_type = "bool", - example = r#" - # Enable preview features - preview = true - "# - )] - pub preview: Option, - /// A list of task tags to recognize (e.g., "TODO", "FIXME", "XXX"). /// /// Comments starting with these tags will be ignored by commented-out code @@ -555,25 +589,13 @@ pub struct Options { #[option( default = r#"["TODO", "FIXME", "XXX"]"#, value_type = "list[str]", - example = r#"task-tags = ["HACK"]"# + example = r#" + [lint] + task-tags = ["HACK"] + "# )] pub task_tags: Option>, - /// A list of modules whose exports should be treated equivalently to - /// members of the `typing` module. - /// - /// This 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. - #[option( - default = r#"[]"#, - value_type = "list[str]", - example = r#"typing-modules = ["airflow.typing_compat"]"# - )] - pub typing_modules: Option>, - /// A list of rule codes or prefixes to consider non-autofix-able. #[option( default = "[]", diff --git a/crates/ruff_workspace/src/pyproject.rs b/crates/ruff_workspace/src/pyproject.rs index cf6fb30893b2e4..0e821655c4c8d2 100644 --- a/crates/ruff_workspace/src/pyproject.rs +++ b/crates/ruff_workspace/src/pyproject.rs @@ -161,7 +161,7 @@ mod tests { use ruff_linter::line_width::LineLength; use ruff_linter::settings::types::PatternPrefixPair; - use crate::options::Options; + use crate::options::{LintOptions, Options}; use crate::pyproject::{find_settings_toml, parse_pyproject_toml, Pyproject, Tools}; use crate::tests::test_resource_path; @@ -236,7 +236,10 @@ select = ["E501"] pyproject.tool, Some(Tools { ruff: Some(Options { - select: Some(vec![codes::Pycodestyle::E501.into()]), + lint_legacy: LintOptions { + select: Some(vec![codes::Pycodestyle::E501.into()]), + ..LintOptions::default() + }, ..Options::default() }) }) @@ -254,8 +257,11 @@ ignore = ["E501"] pyproject.tool, Some(Tools { ruff: Some(Options { - extend_select: Some(vec![codes::Ruff::_100.into()]), - ignore: Some(vec![codes::Pycodestyle::E501.into()]), + lint_legacy: LintOptions { + extend_select: Some(vec![codes::Ruff::_100.into()]), + ignore: Some(vec![codes::Pycodestyle::E501.into()]), + ..LintOptions::default() + }, ..Options::default() }) }) @@ -308,10 +314,14 @@ other-attribute = 1 "migrations".to_string(), "with_excluded_file/other_excluded_file.py".to_string(), ]), - per_file_ignores: Some(FxHashMap::from_iter([( - "__init__.py".to_string(), - vec![codes::Pyflakes::_401.into()] - )])), + + lint_legacy: LintOptions { + per_file_ignores: Some(FxHashMap::from_iter([( + "__init__.py".to_string(), + vec![codes::Pyflakes::_401.into()] + )])), + ..LintOptions::default() + }, ..Options::default() } ); diff --git a/ruff.schema.json b/ruff.schema.json index bfad9f5c5eb8ed..028e34d01ac138 100644 --- a/ruff.schema.json +++ b/ruff.schema.json @@ -377,6 +377,17 @@ "maximum": 320.0, "minimum": 1.0 }, + "lint": { + "description": "Options for the Ruff linter", + "anyOf": [ + { + "$ref": "#/definitions/LintOptions" + }, + { + "type": "null" + } + ] + }, "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`).", "type": [ @@ -1410,6 +1421,418 @@ "format": "uint16", "minimum": 1.0 }, + "LintOptions": { + "type": "object", + "properties": { + "allowed-confusables": { + "description": "A list of allowed \"confusable\" Unicode characters to ignore when enforcing `RUF001`, `RUF002`, and `RUF003`.", + "type": [ + "array", + "null" + ], + "items": { + "type": "string", + "maxLength": 1, + "minLength": 1 + } + }, + "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_`.", + "type": [ + "string", + "null" + ] + }, + "extend-fixable": { + "description": "A list of rule codes or prefixes to consider autofixable, in addition to those specified by `fixable`.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/RuleSelector" + } + }, + "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`.", + "type": [ + "object", + "null" + ], + "additionalProperties": { + "type": "array", + "items": { + "$ref": "#/definitions/RuleSelector" + } + } + }, + "extend-select": { + "description": "A list of rule codes or prefixes to enable, in addition to those specified by `select`.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/RuleSelector" + } + }, + "external": { + "description": "A list of rule codes 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.", + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + } + }, + "fixable": { + "description": "A list of rule codes or prefixes to consider autofixable. By default, all rules are considered autofixable.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/RuleSelector" + } + }, + "flake8-annotations": { + "description": "Options for the `flake8-annotations` plugin.", + "anyOf": [ + { + "$ref": "#/definitions/Flake8AnnotationsOptions" + }, + { + "type": "null" + } + ] + }, + "flake8-bandit": { + "description": "Options for the `flake8-bandit` plugin.", + "anyOf": [ + { + "$ref": "#/definitions/Flake8BanditOptions" + }, + { + "type": "null" + } + ] + }, + "flake8-bugbear": { + "description": "Options for the `flake8-bugbear` plugin.", + "anyOf": [ + { + "$ref": "#/definitions/Flake8BugbearOptions" + }, + { + "type": "null" + } + ] + }, + "flake8-builtins": { + "description": "Options for the `flake8-builtins` plugin.", + "anyOf": [ + { + "$ref": "#/definitions/Flake8BuiltinsOptions" + }, + { + "type": "null" + } + ] + }, + "flake8-comprehensions": { + "description": "Options for the `flake8-comprehensions` plugin.", + "anyOf": [ + { + "$ref": "#/definitions/Flake8ComprehensionsOptions" + }, + { + "type": "null" + } + ] + }, + "flake8-copyright": { + "description": "Options for the `flake8-copyright` plugin.", + "anyOf": [ + { + "$ref": "#/definitions/Flake8CopyrightOptions" + }, + { + "type": "null" + } + ] + }, + "flake8-errmsg": { + "description": "Options for the `flake8-errmsg` plugin.", + "anyOf": [ + { + "$ref": "#/definitions/Flake8ErrMsgOptions" + }, + { + "type": "null" + } + ] + }, + "flake8-gettext": { + "description": "Options for the `flake8-gettext` plugin.", + "anyOf": [ + { + "$ref": "#/definitions/Flake8GetTextOptions" + }, + { + "type": "null" + } + ] + }, + "flake8-implicit-str-concat": { + "description": "Options for the `flake8-implicit-str-concat` plugin.", + "anyOf": [ + { + "$ref": "#/definitions/Flake8ImplicitStrConcatOptions" + }, + { + "type": "null" + } + ] + }, + "flake8-import-conventions": { + "description": "Options for the `flake8-import-conventions` plugin.", + "anyOf": [ + { + "$ref": "#/definitions/Flake8ImportConventionsOptions" + }, + { + "type": "null" + } + ] + }, + "flake8-pytest-style": { + "description": "Options for the `flake8-pytest-style` plugin.", + "anyOf": [ + { + "$ref": "#/definitions/Flake8PytestStyleOptions" + }, + { + "type": "null" + } + ] + }, + "flake8-quotes": { + "description": "Options for the `flake8-quotes` plugin.", + "anyOf": [ + { + "$ref": "#/definitions/Flake8QuotesOptions" + }, + { + "type": "null" + } + ] + }, + "flake8-self": { + "description": "Options for the `flake8_self` plugin.", + "anyOf": [ + { + "$ref": "#/definitions/Flake8SelfOptions" + }, + { + "type": "null" + } + ] + }, + "flake8-tidy-imports": { + "description": "Options for the `flake8-tidy-imports` plugin.", + "anyOf": [ + { + "$ref": "#/definitions/Flake8TidyImportsOptions" + }, + { + "type": "null" + } + ] + }, + "flake8-type-checking": { + "description": "Options for the `flake8-type-checking` plugin.", + "anyOf": [ + { + "$ref": "#/definitions/Flake8TypeCheckingOptions" + }, + { + "type": "null" + } + ] + }, + "flake8-unused-arguments": { + "description": "Options for the `flake8-unused-arguments` plugin.", + "anyOf": [ + { + "$ref": "#/definitions/Flake8UnusedArgumentsOptions" + }, + { + "type": "null" + } + ] + }, + "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.", + "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`).", + "type": [ + "boolean", + "null" + ] + }, + "isort": { + "description": "Options for the `isort` plugin.", + "anyOf": [ + { + "$ref": "#/definitions/IsortOptions" + }, + { + "type": "null" + } + ] + }, + "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`).", + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + } + }, + "mccabe": { + "description": "Options for the `mccabe` plugin.", + "anyOf": [ + { + "$ref": "#/definitions/McCabeOptions" + }, + { + "type": "null" + } + ] + }, + "pep8-naming": { + "description": "Options for the `pep8-naming` plugin.", + "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.", + "type": [ + "object", + "null" + ], + "additionalProperties": { + "type": "array", + "items": { + "$ref": "#/definitions/RuleSelector" + } + } + }, + "pycodestyle": { + "description": "Options for the `pycodestyle` plugin.", + "anyOf": [ + { + "$ref": "#/definitions/PycodestyleOptions" + }, + { + "type": "null" + } + ] + }, + "pydocstyle": { + "description": "Options for the `pydocstyle` plugin.", + "anyOf": [ + { + "$ref": "#/definitions/PydocstyleOptions" + }, + { + "type": "null" + } + ] + }, + "pyflakes": { + "description": "Options for the `pyflakes` plugin.", + "anyOf": [ + { + "$ref": "#/definitions/PyflakesOptions" + }, + { + "type": "null" + } + ] + }, + "pylint": { + "description": "Options for the `pylint` plugin.", + "anyOf": [ + { + "$ref": "#/definitions/PylintOptions" + }, + { + "type": "null" + } + ] + }, + "pyupgrade": { + "description": "Options for the `pyupgrade` plugin.", + "anyOf": [ + { + "$ref": "#/definitions/PyUpgradeOptions" + }, + { + "type": "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.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/RuleSelector" + } + }, + "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`.", + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + } + }, + "unfixable": { + "description": "A list of rule codes or prefixes to consider non-autofix-able.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/RuleSelector" + } + } + }, + "additionalProperties": false + }, "McCabeOptions": { "type": "object", "properties": {