Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a grouping rule for ruff formatter conflicting rules #8175

Open
gaborbernat opened this issue Oct 24, 2023 · 4 comments
Open

Provide a grouping rule for ruff formatter conflicting rules #8175

gaborbernat opened this issue Oct 24, 2023 · 4 comments
Labels
formatter Related to the formatter wish Not on the current roadmap; maybe in the future

Comments

@gaborbernat
Copy link
Contributor

Ruff warns these rules conflict with the formatter, would be nice if we could disable these in a single line then need to disable one by one:

  "COM812", # conflicts with formatter
  "COM819", # conflicts with formatter
  "E501", # conflicts with formatter
  "ISC001", # conflicts with formatter
  "Q000", # conflicts with formatter
  "Q001", # conflicts with formatter
  "Q002", # conflicts with formatter
  "Q003", # conflicts with formatter
  "W191", # conflicts with formatter

perhaps we could have rule FORM1 that would be an alias to all the rules conflicting with ruff formatter?

@zanieb zanieb added the formatter Related to the formatter label Oct 24, 2023
@Avasam
Copy link

Avasam commented Oct 24, 2023

My use case: I currently include "ALL" rules and deactivate the few groups and rules I don't want or conflict with type-checkers or formatters.
I don't really care about superfluous or unused rules because Ruff is so darn fast.

This ends up being less maintenance for me to stay up to date with new rules. And it's easier to document with comments what we don't want or agree with.

But having a way to configure "ALL but rules obsoleted by formatter" would be nice to simplify configs (and automatically stay up to date with formatter updates!).

I don't know if 501 should be included here though. Sometimes formatter can't go under max line length and it requires a manual fix (like cutting a string, moving a comment, etc)

@MichaReiser
Copy link
Member

#8196 removes the warnings for all but 2 rules, except if you changed the configuration for some of the potentially conflicting rules.

charliermarsh pushed a commit that referenced this issue Oct 26, 2023
## 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 #8175
and #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.
@MichaReiser
Copy link
Member

The latest release shipped a few improvements that should drastically reduce the warnings. Please take a look and comment on this issue if you think that a dedicated grouping for conflicting rules would still be valuable and we'll reopen the issue.

@MichaReiser MichaReiser closed this as not planned Won't fix, can't repro, duplicate, stale Oct 27, 2023
@gaborbernat
Copy link
Contributor Author

As long as the number is greater than one, I think it would still be helpful. So I'm asking to reopen this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
formatter Related to the formatter wish Not on the current roadmap; maybe in the future
Projects
None yet
Development

No branches or pull requests

4 participants