Skip to content

New Rule + fixer: Use a list instead of calling split with string literals #13944

@Avasam

Description

@Avasam

I've seen this pattern a handful of time:

"""
	itemA
	itemB
	itemC
""".split()

or

"a,b,c,d".split(",")

And I'd like a rule to transform usages of join with literals into actual inline lists without the overhead of calling "join". My two examples above would become:

[
	"itemA",
	"itemB",
	"itemC",
]

or

["a", "b", "c", "d"]

I don't think this rule exists in any linters that I'm aware of.

The exact details of how this gets formatted isn't important to this rule. Probably just rewrite everything on a single line and let formatting/other rules take care of the rest.

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedReady for implementationruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions