Refine the warnings about incompatible linter options (#8196)

## Summary

Avoid warning about incompatible rules except if their configuration
directly conflicts with the formatter. This should reduce the noise and
potentially the need for https://github.com/astral-sh/ruff/issues/8175
and https://github.com/astral-sh/ruff/issues/8185

I also extended the rule and option documentation to mention any
potential formatter incompatibilities or whether they're redundant when
using the formatter.

* `LineTooLong`: This is a use case we explicitly want to support. Don't
warn about it
* `TabIndentation`, `IndentWithSpaces`: Only warn if
`indent-style="tab"`
* `IndentationWithInvalidMultiple`,
`IndentationWithInvalidMultipleComment`: Only warn if `indent-width !=
4`
* `OverIndented`: Don't warn, but mention that the rule is redundant
* `BadQuotesInlineString`: Warn if quote setting is different from
`format.quote-style`
* `BadQuotesMultilineString`, `BadQuotesDocstring`: Warn if `quote !=
"double"`

## Test Plan

I added a new integration test for the default configuration with `ALL`.
`ruff format` now only shows two incompatible rules, which feels more
reasonable.
This commit is contained in:
Micha Reiser 2023-10-27 01:22:56 +09:00 committed by GitHub
parent be3307e9a6
commit a4dd1e5fad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 247 additions and 49 deletions

View file

@ -1412,6 +1412,9 @@ impl Flake8PytestStyleOptions {
pub struct Flake8QuotesOptions {
/// Quote style to prefer for inline strings (either "single" or
/// "double").
///
/// When using the formatter, ensure that `format.quote-style` is set to
/// the same preferred quote style.
#[option(
default = r#""double""#,
value_type = r#""single" | "double""#,
@ -1423,6 +1426,9 @@ pub struct Flake8QuotesOptions {
/// Quote style to prefer for multiline strings (either "single" or
/// "double").
///
/// When using the formatter, only "double" is compatible, as the formatter
/// enforces double quotes for multiline strings.
#[option(
default = r#""double""#,
value_type = r#""single" | "double""#,
@ -1433,6 +1439,9 @@ pub struct Flake8QuotesOptions {
pub multiline_quotes: Option<Quote>,
/// Quote style to prefer for docstrings (either "single" or "double").
///
/// When using the formatter, only "double" is compatible, as the formatter
/// enforces double quotes for docstrings strings.
#[option(
default = r#""double""#,
value_type = r#""single" | "double""#,