Hello,
It is quite common to use f-strings for large error messages that would not fit on a single line of code, depending on your conventions (and readability preferences).
The idiomatic way around this is, of course, string continuations. However, it then comes up relatively often that some segments of the string continuation don’t have a formatting pattern in them.
What should be the stylistic preference then? Should all segments of a f-string continuation have a f
in front of them, or only those that are actually templated?
Concrete example: which one should be preferred and why? (possible concerns include: maintainability, readability, performance)
raise click.ClickException(
f"There is no service/image defined in docker-compose.yml with "
f"the given name: {e}"
)
or
raise click.ClickException(
"There is no service/image defined in docker-compose.yml with "
f"the given name: {e}"
)
(please don’t answer that the error message should be phrased more concisely, or that I should just accept a larger line width - that’s off-topic here )