Skip to content

[string_preprocessing] When splitting lines, \n is ignored #1467

@Jackenmen

Description

@Jackenmen

Describe the style change
[string_preprocessing] Black should respect new lines (\n) in strings.

Input:

message = (
    "1. Go to Google Developers Console and log in with your favourite Google account.\n"
    "(https://console.developers.google.com/)\n"
    "2. You should be prompted to create a new project (name does not matter).\n"
    "3. Click on Enable APIs and Services at the top.\n"
    "4. In the list of APIs choose or search for YouTube Data API v3 and "
    "click on it. Choose Enable.\n"
    "5. Click on Credentials on the left navigation bar.\n"
    "6. Click on Create Credential at the top.\n"
    '7. At the top click the link for "API key".\n'
    "8. No application restrictions are needed. Click Create at the bottom.\n"
    "9. You now have a key to add to `[p]set api youtube api_key <your_api_key_here>`"
)

Examples in the current Black style:

message = (
    "1. Go to Google Developers Console and log in with your favourite Google"
    " account.\n(https://console.developers.google.com/)\n2. You should be prompted to"
    " create a new project (name does not matter).\n3. Click on Enable APIs and"
    " Services at the top.\n4. In the list of APIs choose or search for YouTube Data"
    " API v3 and click on it. Choose Enable.\n5. Click on Credentials on the left"
    " navigation bar.\n6. Click on Create Credential at the top.\n7. At the top click"
    ' the link for "API key".\n8. No application restrictions are needed. Click Create'
    " at the bottom.\n9. You now have a key to add to `[p]set api youtube api_key"
    " <your_api_key_here>`"
)

Desired style:
(place in which I split the 1. is random, I just mean that Black should respect \n)

message = (
    "1. Go to Google Developers Console and log in with your favourite"
    " Google account.\n"
    "(https://console.developers.google.com/)\n"
    "2. You should be prompted to create a new project (name does not matter).\n"
    "3. Click on Enable APIs and Services at the top.\n"
    "4. In the list of APIs choose or search for YouTube Data API v3 and "
    "click on it. Choose Enable.\n"
    "5. Click on Credentials on the left navigation bar.\n"
    "6. Click on Create Credential at the top.\n"
    '7. At the top click the link for "API key".\n'
    "8. No application restrictions are needed. Click Create at the bottom.\n"
    "9. You now have a key to add to `[p]set api youtube api_key <your_api_key_here>`"
)

Additional context:
None

I'm sorry for the amount of issues but I tried to run Black's master on Cog-Creators/Red-DiscordBot's code base which resulted in quite a few of errors and also some undesired (by me) changes which I wanted to at least report even if they're not gonna be changed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: preview styleIssues with the preview and unstable style. Add the name of the responsible feature in the title.F: stringsRelated to our handling of stringsT: styleWhat do we want Blackened code to look like?

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions