wemake-services / wemake-services/wemake-python-styleguide

Detect missed trailing whitespace in concatenated messages

Open
#1,835 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

rule request
Dominant language
Python
Stars
2.9k
Forks
430
Avg merge
5h 14m
Merged PRs (30d)
34

Description

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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the proposed examples and deciding how to distinguish human-facing messages from SQL, URLs, and other machine-oriented concatenations. Define the heuristic and its edge cases, then add coverage showing that missed whitespace is reported without flagging valid concatenation; no implementation files or tests are named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.