-
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 removing ISC001
from the conflict list with ruff format
#8272
Comments
Thanks for reporting and opening a new issue. I think we didn't make an explicit decision, but we merged the improvements we had to include them in 0.1.3 Rules and options that are compatible with the formatter should have the following properties:
I do see how I don't have a good answer yet about what we should do about these rules. Warning seems appropriate because you can run into situations where you must run |
I fully agree with the intent I'm mixed about I get that this way of thinking is a bit changed because of the |
If we imagine a world in which |
Anyways, thank you very much for the openness and allowing discussions about all this, as well as the quick iterative fixes |
Unfortunately, this is not guaranteed. Applying an autofixes may produce code that now exceeds the preferred line width or the formatter can now collapse multiple lines. That means, it is generally necessary to run the formatter after linting. |
Oh really? I'm surprised as rules like SIM108 do not trigger if there is no place for the fix within the specified line-length. Maybe it depends on the rules then |
Yeah, some rules have this check, but not all of them. However, all fixes that remove (or change code) may reduce the length of lines, possibly causing reformats. |
Ah okay I get it. It would be best if the fixes of In that case should I go back advocating for a way to suppress warning about rules breaking point 1? My use case is to be warned about |
I really don't want warnings every time I run This rule is not incompatible with the formatter in the same way as |
I hear your feedback and I see how |
@tylerlaprade What do you mean under |
One option for addressing this issue is to change our formatter, see #9457. However, there's a caveat. The new formatting would be non-reversible and I'm undecided if we should accept that or wait until we implement Black's string processing preview style. Please comment on the linked issue if you would object to the formatter making this change automatically for you. |
I don't know if this is useful to anyone, but my current local lint script runs:
If the final check fails then I assume manual intervention will be required to make sure my check/format config is compatible, or perhaps to manually reformat some bit of code that's triggering incompatibilities. In some cases re-runs without intervention could reach a stable state. Is this the expected usage of ruff? If so then it does feel like ruff itself could provide that workflow in a combined "fix my code using all my config" command. Currently it feels like |
ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: astral-sh/ruff#8272
ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: astral-sh/ruff#8272
ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: astral-sh/ruff#8272
ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: astral-sh/ruff#8272
ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: astral-sh/ruff#8272
ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: astral-sh/ruff#8272
ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: astral-sh/ruff#8272
ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: astral-sh/ruff#8272
ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: astral-sh/ruff#8272
ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: astral-sh/ruff#8272
ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: astral-sh/ruff#8272
ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: astral-sh/ruff#8272
Another option could be a way to disable the warning per rule like: [tool.ruff.format]
disable-rule-conflict-warning = ["ICS001"] That way I'm explicitly stating that I understand that I might have to run the formatter and |
ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: astral-sh/ruff#8272
ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: astral-sh/ruff#8272
ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: astral-sh/ruff#8272
This comment was marked as resolved.
This comment was marked as resolved.
ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: astral-sh/ruff#8272
It gives a warning when running the Ruff formatter. This rule can cause the linter and formatter to conflict, meaning you need to rerun `ruff check --fix` again after `ruff format`. See astral-sh/ruff#8272 (comment)
It gives a warning when running the Ruff formatter. This rule can cause the linter and formatter to conflict, meaning you need to rerun `ruff check --fix` again after `ruff format`. See astral-sh/ruff#8272 (comment)
Preview mode now comes with #13663. This isn't enough to fix the incompatibility because the preview style doesn't support triple quoted and raw strings. A simple way of solving the incompatibility is to always format raw and triple quoted implicitly concatenated strings over multiple lines (except when in unparenthesized statement positions). This fixes the incompatibility and, arguably, also makes the implicit concat more visible. a = r"test" "other" would be formatted as a = (
r"test"
"other"
) Any thoughts on this? |
Reminder on the rule: Checks for implicitly concatenated strings on a single line.
Why I believe there is actually no conflict with ruff format on default settings:
Imagine a situation where the formatter puts two strings on the same line:
foo = "foo" "bar"
If the rule is activated (and a fix available), the line will become:
foo = "foobar"
Which will not be further modified by ruff format.
However, if the rule is not activated, it will stay like:
foo = "foo" "bar"
I assume some people will want to be warned about this appearing because of the formatter and will want to fix it, hence
ISC001
being useful alongside ruff format.Am I missing something on the incompatibility between this rule and ruff format?
The text was updated successfully, but these errors were encountered: