ruff: Consider removing `ISC001` from the conflict list with ruff format
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?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 32
- Comments: 17 (7 by maintainers)
Commits related to this issue
- MNT: Apply ruff/flake8-implicit-str-concat rule ISC001 ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: https://g... — committed to DimitriPapadopoulos/mriqc by DimitriPapadopoulos 3 years ago
- STY: Apply ruff/flake8-implicit-str-concat rule ISC001 ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: https://g... — committed to DimitriPapadopoulos/mriqc by DimitriPapadopoulos 3 years ago
- STY: Apply ruff/flake8-implicit-str-concat rule ISC001 ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: https://g... — committed to DimitriPapadopoulos/nireports by DimitriPapadopoulos 3 years ago
- STY: Apply ruff/flake8-implicit-str-concat rule ISC001 ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: https://g... — committed to DimitriPapadopoulos/niworkflows by DimitriPapadopoulos 3 years ago
- STY: Apply ruff/flake8-implicit-str-concat rule ISC001 ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: https://g... — committed to DimitriPapadopoulos/fmriprep by DimitriPapadopoulos 3 years ago
- STY: Apply ruff/flake8-implicit-str-concat rule ISC001 (#870) ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: htt... — committed to nipreps/niworkflows by DimitriPapadopoulos 3 years ago
- STY: Apply ruff/flake8-implicit-str-concat rule ISC001 ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: https://g... — committed to DimitriPapadopoulos/smriprep by DimitriPapadopoulos 3 years ago
- STY: Apply ruff/flake8-implicit-str-concat rule ISC001 (#436) ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: htt... — committed to nipreps/smriprep by DimitriPapadopoulos 3 years ago
- Apply ruff/flake8-implicit-str-concat rule ISC001 ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: https://github... — committed to DimitriPapadopoulos/filesystem_spec by DimitriPapadopoulos 3 years ago
- Apply ruff/flake8-implicit-str-concat rule ISC001 ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: https://github... — committed to DimitriPapadopoulos/mne-python by DimitriPapadopoulos 3 years ago
- Apply ruff/flake8-implicit-str-concat rule ISC001 ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: https://github... — committed to DimitriPapadopoulos/mne-python by DimitriPapadopoulos 3 years ago
- Manually apply ruff/flake8-implicit-str-concat rule ISC001 ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: https... — committed to DimitriPapadopoulos/mne-python by DimitriPapadopoulos 3 years ago
- Manually apply ruff/flake8-implicit-str-concat rule ISC001 ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: https... — committed to DimitriPapadopoulos/mne-python by DimitriPapadopoulos 3 years ago
- Apply ruff/flake8-implicit-str-concat rule ISC001 ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: https://github... — committed to DimitriPapadopoulos/mne-python by DimitriPapadopoulos 3 years ago
- Manually apply ruff/flake8-implicit-str-concat rule ISC001 ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: https... — committed to DimitriPapadopoulos/mne-python by DimitriPapadopoulos 3 years ago
- Apply ruff/flake8-implicit-str-concat rule ISC001 ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: https://github... — committed to DimitriPapadopoulos/neurospin_to_bids by DimitriPapadopoulos 3 years ago
- STY: Apply ruff/flake8-implicit-str-concat rule ISC001 ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: https://g... — committed to DimitriPapadopoulos/nibabel by DimitriPapadopoulos 3 years ago
- STY: Apply ruff/flake8-implicit-str-concat rule ISC001 ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: https://g... — committed to DimitriPapadopoulos/mne-python by DimitriPapadopoulos 3 years ago
- STY: Manually apply ruff/flake8-implicit-str-concat rule ISC001 ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: ... — committed to DimitriPapadopoulos/mne-python by DimitriPapadopoulos 3 years ago
- Apply ruff/flake8-implicit-str-concat rule ISC001 (#10932) ISC001 Implicitly concatenated string literals on one line This rule is currently disabled because it conflicts with the formatter: htt... — committed to pyca/cryptography by DimitriPapadopoulos 3 years ago
I hear your feedback and I see how
ISC001is useful even when used with the formatter. The issue is on my to do list I just haven’t gotten around to look at it in more detail.I really don’t want warnings every time I run
ruff format. I might personally know that it’s safe to ignore, but this is bound to confuse more junior members of my team. For reference, when I previously pre-emptively includedFURBin our config so it would be enabled as soon as it was out of preview, they saw the warnings about--previewwhen runningruff format, thought they had to runruff format --previewinstead, and ended up with >80 changed files in an otherwise tiny PR.This rule is not incompatible with the formatter in the same way as
ISC003orE501. Moreover, disabling this rule would easily allow bugs to creep in, because it’s never the case that someone intentionally concatenates two strings in a line without an f-string or+sign.Looks like this was released as part of 0.9.0
Another option could be a way to disable the warning per rule like:
That way I’m explicitly stating that I understand that I might have to run the formatter and
check --fixback and forth, and maybe do some manual intervention even, to get it to all pass, for this rule specifically.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
ruff checkandruff formatare two separate tools that happen to be in the same executable, with a bit of work left to do meet the potential goal of bringing black formatting into ruff “proper”, in the way that (for example) isort formatting already has been. Which is fine, because both ruff commands work really well, it just requires a bit of research to figure out how to run ruff at the moment.Ah okay I get it. It would be best if the fixes of
ruff check --fixwould be compliant with the formatter settings imo, but I see the ruff approach is more to runformataftercheck.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
implicitly concatenated strings on a single linewithout warnings ideally.Anyways, thank you very much for the openness and allowing discussions about all this, as well as the quick iterative fixes
If we imagine a world in which
formatandcheckare combined, I believe we can expectformat + fixaccording to the rules, and the the remaining violations are displayed to the user. In this context, havingISC001on would not bring any contradiction, it would just specify “format my code and make sure strings are concatenated”, which is exactly what I want to express in my pipeline, by runningformatand thencheckwithISC001Unfortunately, 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.
I fully agree with the intent
2., no doubt about it.I’m mixed about
1.It is easily fixed if you run the formatter before the linter, thing that was mandatory at the time ofblackandflake8: the formatter would preemptively fix some code that would otherwise be a violation for the linter (lines too long for example, would be fixed by the formatter).I get that this way of thinking is a bit changed because of the
--fixflag, but still I believe it’s more appropriate to have a pipeline with formatting first and linter as second, as you don’t expectcheck --fixto “break the format” of some code, unless you have actual contradictions within your rules (breaking point2.)