You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have soft rule in our code base that means we should prefix all multiline f-strings with an f even if no interpolation is happening on part of the string. For example, instead of doing this:
long_string= (
"This is a long string to demonstrate that when it wraps on to the next "f"line, all lines should be prefixed with an {f_prefix} to improve ""readability and effectively treat them along the same lines as a trailing ""comma, even if interpolation only happens on a subset of the lines."
)
We should be doing this:
long_string= (
f"This is a long string to demonstrate that when it wraps on to the next "f"line, all lines should be prefixed with an {f_prefix} to improve "f"readability and effectively treat them along the same lines as a trailing "f"comma, even if interpolation only happens on a subset of the lines."
)
Is there an existing rule that can catch this linting error? If not, can I request one be added please?
The text was updated successfully, but these errors were encountered:
Does this rule of yours only apply if one of the string literals contain an expression or for all implicit concatenated strings?
E.g. what about
long_string= (
"This is a long string to demonstrate that when it wraps on to the next ""line, all lines should be prefixed with an ... to improve ""readability and effectively treat them along the same lines as a trailing ""comma, even if interpolation only happens on a subset of the lines."
)
Does this rule of yours only apply if one of the string literals contain an expression or for all implicit concatenated strings?
Yes, only if at some point a variable is being interpolated into it. If it's a multiline string with no interpolation, then we do not prefix with an f.
Thanks. I now understand your use case. We could phrase it in a more general way and say that you want a common prefix for all string literals in implicit concatenated strings. The rule would then also enforce that all strings are raw-strings
We have soft rule in our code base that means we should prefix all multiline f-strings with an
f
even if no interpolation is happening on part of the string. For example, instead of doing this:We should be doing this:
Is there an existing rule that can catch this linting error? If not, can I request one be added please?
The text was updated successfully, but these errors were encountered: