Proposed Check: Unintentional str concat
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 123
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 5
Description
One of the common mistakes I can make is to miss out a comma in collections of literal strings, resulting in the strings being concatenated.
my_list = ["a", "b", "c" "d"] # note the missing comma between 'c' and 'd'
print(my_list) # ["a", "b", "cd"]
I've not come across a time I've ever used this intentionally, and will either explicitly write "c" + "d" or use a format string "{a} {b} when a and b are variables.
If you intend this using brackets might be a fine way. my_list = ["a", "b", ("c" "d")]. Similar to the trailing comma tuple mistake where flake8-comma flags my_int = 5, but allows the more explicit my_int = (5,).
The above would mean multiline strings could be concerted still as:
my_multiline = (
"part one "
"part two"
)
As soon as a comma is introduced though it becomes a tuple, and I'd argue each str literal should have a comma between it or none should.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no files, tests, or entry points; use its examples as the behavioral starting point. Done means the check identifies unintended adjacent string literals in collections while permitting explicitly grouped multiline strings and intentional concatenation.
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
- Mostly clear
- Newbie friendliness
- 35/100