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

Indentation of method call after multiline string #2028

Closed
Samrose-Ahmed opened this issue Mar 8, 2021 · 1 comment
Closed

Indentation of method call after multiline string #2028

Samrose-Ahmed opened this issue Mar 8, 2021 · 1 comment
Labels
R: duplicate This issue or pull request already exists T: bug Something isn't working

Comments

@Samrose-Ahmed
Copy link

Note: Reading the docs, not sure if this a bug or style request

Describe the bug

Black oddly indents method calls on string after long multiline string. A very common python usecase it write a long mutliline
string and follow it with e.g. .replace("\n", " ").

To Reproduce
Steps to reproduce the behavior:

  1. Take this file '...'
long_text = """Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the
industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to
make a specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining
essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum
passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.\
""".replace("\n", " ")
  1. Run Black on it with these arguments (line length 120)
  2. See:
long_text = """Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the
industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to
make a specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining
essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum
passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.\
""".replace(
    "\n", " "
)

Expected behavior A clear and concise description of what you expected to happen.

long_text = """Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the
industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to
make a specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining
essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum
passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.\
""".replace("\n", " ")

It gets even worse as we chain the calls e.g.

long_text = """Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the
industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to
make a specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining
essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum
passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.\
""".replace(
    "\n", " "
).replace(
    "\t", " "
)

Environment (please complete the following information):

  • Version: 20.8b1
  • OS and Python version: [ Linux/Python 3.8.8]

Does this bug also happen on master? To answer this, you have two options:
Yes

Additional context Add any other context about the problem here.

I can get around this with:

long_text = """Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the
industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to
make a specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining
essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum
passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.\
"""
long_text = long_text.replace("\n", " ").replace("\t", " ")

But it seems a bit odd just to satisfy the formatter. Is this expected based on the style?

@Samrose-Ahmed Samrose-Ahmed added the T: bug Something isn't working label Mar 8, 2021
@ichard26 ichard26 added the R: duplicate This issue or pull request already exists label Apr 2, 2021
@ichard26
Copy link
Collaborator

ichard26 commented Apr 2, 2021

Duplicate of #256.

@ichard26 ichard26 closed this as completed Apr 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
R: duplicate This issue or pull request already exists T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants