-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Consider adding an option to supress ruff format CLI warnings #8185
Comments
Thanks for reporting. Which of the conflicting rules do you want to use alongside the formatter and what's the use case for having both enabled (what do they catch in addition to the formatter)? |
(It sounds like one example is: using isort with different settings; so you run the formatter, then linter, to get formatted code with different import settings (which would then be reformatted if you re-ran the formatter).) |
Yeah I use I also have a warning about a bunch of other conflicts ('D206', 'E501', 'ISC001', 'Q000', 'Q001', 'Q002', 'Q003', 'W191'). My configuration might be weird, I have
And actually if I stop running Also I would not want to disable all ruff warnings, only these rule conflict warnings. |
I hit this as well, with a very vanilla configuration - no custom isort options, etc. but we have a blanket
The W191 seems like it could only be displayed when you have customized the formatter to use tabs instead of spaces. E501 seems like a harder case since most of the time it won't be an issue but there are a difficult cases (long comments, etc.) where it might be an issue. I wonder whether this might be as simple as implementing #8175 or trying something clever see whether the |
Thanks for explaining. We intentionally allow E501 because some projects use E501 to warn about extra long lines (e.g. line-length: 80 and pycodestyle.max-line-length: 100).
I like this |
!!! You guys are fast, well done! It's a bit better, I get different ones now. I'm still not convinced by the warnings. If we take the linter as an example, there is not such warning and it's up to the user to make sure they didn't activate conflicting rules isn't it? Moreover, I still don't understand how the rules included in the warning conflict with the formatter with default settings: ('D206', 'E501', 'ISC001', 'Q000', 'Q001', 'Q002', 'Q003', 'W191') |
Did you build from source? The changes are not yet released. |
Yes yes I used the master branch from a few minutes ago. I no longer have the conflict about |
Oh nice! Can you try #8196? It isn't yet merged. Feel free to comment directly on the PR. |
Tested on my project, only have a warning about Don't know if I should open a new issue, but I feel like the warning about |
Could you share your configuration and what warning your seeing. It should never warn about |
Ah no I don't have My config:
|
I think that's actually correct. If you add the trailing comma after the last alias as in this example: from a import (b, c,) Then from a import (
b,
c,
) Now, from a import b, c That's why you either have to override the default of Either way, I think we should extend the |
But this will not happen because I have Instead, isort will format to: from a import b
from a import c Which is not a problem for the formatter. Now the question is more "how far should you go in the combination of options" |
Perhaps we could combine this request with a mechanism by which we automatically disable conflicting lint rules and options -- something like |
That sounds interesting. I recommend making such option tooling independent (e.g. disabling conflicting rules etc). Having a tool specific name also opens the question of where it should be placed in the configuration. Under |
We actually do have warnings in the linter like this too e.g.
What do you mean? Like |
Kind of, but ideally more generic: Alternatives: |
Hm that seems really broad... I probably want different behavior depending on the category of conflict but perhaps this is a good start. Maybe |
Well I opened this issue with this in mind, but when I see all the great work aiming at making the warnings represent actual conflicts and remove false-positive, I'm not sure it's really necessary anymore. Don't know about others, but #8196 and #8244 will probably remove all the warnings for my use cases. |
## 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.
…is true (#8244) ## Summary Based on [this feedback](#8185 (comment)). Avoid warning about `force-wrap-aliases` and `split-on-trailing-comma` if `force-single-line` is true (which creates a dedicated import for each imported member). ## Test Plan Ran `ruff format . --no-cache` and verified that the warning show up when `force-single-line=false` and aren't shown when `force-single-line=true`
We shipped some improvements in the last release. Please open a new issue if you still encounter issues and would prefer having an option to suppress all format CLI warnings. |
@MichaReiser Thanks for the work this is great. I see you choose not to add |
In I usually do not use the ruff formatter directly, thus only talking about This is a very "nuclear" practice, but suppresses the annoying warnings. |
What is the recommended solution for this @acdha? Edit: turns out, simply update to the latest ruff version solved it. |
Just tried
ruff format
, it's seriously great!I'm just annoyed by the warnings showing up in console:
warning: The following rules may cause conflicts when used with the formatter: XXX
I want my linter (specifically the isort part) taking priority over the formatter, so I run the linter after the formatter and never had problems.
Is there any way to acknowledge / supress the CLI warnings with a configuration option or a command line parameter?
The text was updated successfully, but these errors were encountered: