Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A string that's been split across several lines that needn't be has " " in the middle #2183

Open
fpdotmonkey opened this issue May 3, 2021 · 2 comments
Labels
F: strings Related to our handling of strings S: accepted The changes in this design / enhancement issue have been accepted and can be implemented T: style What do we want Blackened code to look like?

Comments

@fpdotmonkey
Copy link

fpdotmonkey commented May 3, 2021

Describe the style change

Given a split string that is now too short to need to be split, black will combine the string with an implicit concatenation (with " " in the middle) instead of just extending the string. This is ugly, unnecessary, and fails common linters.

Examples in the current Black style

some_variable = (
    "this string needn't be split "
    "because it's too short"
)

# output

some_variable = "this string needn't be split " "because it's too short"

Desired style

some_variable = (
    "this string needn't be split "
    "because it's too short"
)

# output

some_variable = "this string needn't be split because it's too short"

Version information

$ python3 -m black --version
__main__.py, version 20.8b1
$ python3 --version
Python 3.6.9
@fpdotmonkey fpdotmonkey added the T: style What do we want Blackened code to look like? label May 3, 2021
@JelleZijlstra
Copy link
Collaborator

The --experimental-string-processing option will do this. We'll enable it by default once it's sufficiently stable.

@felix-hilden
Copy link
Collaborator

A ref to the issue that will make it the default: #2188

@ichard26 ichard26 added the S: accepted The changes in this design / enhancement issue have been accepted and can be implemented label May 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F: strings Related to our handling of strings S: accepted The changes in this design / enhancement issue have been accepted and can be implemented T: style What do we want Blackened code to look like?
Projects
None yet
Development

No branches or pull requests

4 participants