wemake-python-styleguide
wemake-python-styleguide copied to clipboard
Detect missed trailing whitespace in concatenated messages
Rule request
Thesis
Sometimes, a plaintext message is split by a few separate string literals with concatenation. And sometimes a whitespace is missed. For example:
message = "An error occurred." # <- would have a whitespace at the end.
message += "Try to call for help."
print(message)
# An error occurred.Try to call for help.
Reasoning
For human-facing messages, it is a typo.
Implementation
The challenge is to make an effective heuristic to detect when it is a plain message and when it is something else (for machines). Please, share your examples. Do you have string concatenation for something else rather than for human-facing messages?
Examples I have in mind:
- SQL queries. For them, prefer multiline strings instead of concatenation, SQL databases are pretty fine with newlines in queries.
- URLs. I'd say, it's better just not to split them (see #1182)