-
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
ISC003
gives false positive depending on order of concatenation
#5332
Comments
We should fix the false positive. I suppose we should also change the rule to only flag multi-line concatenations, though the upstream plugin doesn't do that. |
Would making it configurable work? i.e. [flake8-implicit-str-concat]
allow-single-line-explicit = true where the default is to be consistent with the upstream plugin? (i.e. set to false) |
I'd prefer to just remove it (flagging violations on the same line), if we can't find any projects that depend on that behavior. |
(The only way a project would really depend on this is if they have ISC003 enabled but not ISC001 (since "fixing" an ISC003 violation on the same line would yield an ISC001 violation).) |
## Summary Ignore `explicit-string-concatenation` on single line. Closes #5332. ## Test Plan `cargo test`
Another (edge) usecase where the "Extra third case" being flagged, is annoying, is in ploty. Correct : import plotly.graph_objs as go
string = "Data1"
go.Figure(data=go.Scatter(
x=[1.123123,2.12321,3.12321],
y=[1.12321,2.12321,3.12321],
hovertemplate="%{x:.2f}<br>%{y:.3f}" + f"<extra>{string}</extra>")
) The above codeblock but with
Of course the correct version (codeblock) triggers
or when implicitly concatenated:
|
ruff version:
0.0.275
ISC003
gives false positive depending on order of concatenation.First Case (succeeds)
Second case (fails)
I would expect both cases to succeed.
Extra third case
I (personally) would also expect this to succeed. My reading of the
ISC003
docs is that this is aimed at string literals that wrap over multiple lines. Which all the above cases are not.The codebase I'm dealing with has a lot of instances of
"foo" + "bar"
, mainly for clarity reasons, and I don't want those instances flagged. However I do still want this to be raised for multiline strings.If flagging
"foo" + "bar"
is the intended behaviour, could this perhaps be made configurable? i.e. allowing single line instances like that to be ignored while still flagging the multiline cases.The text was updated successfully, but these errors were encountered: