Skip to content

[SIM905] Use list of strings instead of splitting a constant string #86

@MartinThoma

Description

@MartinThoma

Explanation

You want a list of strings? Create one directly:

  • A list of strings can be formatted by black.
  • Your editor can sort the lines
  • You don't have to worry about how to keep leading / intermediate / trailing spaces or how to add newlines to the strings

Example

# Bad
domains = "de com net org".split()

# Good
domains = ["de", "com", "net", "org"]

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions