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

Failing to dedent closing docstring triple-quotes #545

Closed
cas-- opened this issue Oct 1, 2018 · 3 comments
Closed

Failing to dedent closing docstring triple-quotes #545

cas-- opened this issue Oct 1, 2018 · 3 comments
Labels
T: style What do we want Blackened code to look like?

Comments

@cas--
Copy link
Contributor

cas-- commented Oct 1, 2018

I have a function that due to copy-pasting has an extra level of indentation, Black fixes this however it is failing to dedent the closing triple-quote of multi-line docstrings:

def func():
        """A multi-line docstring.
        
        Does nothing.
        """
        pass

results in this:

 def func():
-        """A multi-line docstring.
+    """A multi-line docstring.

         Does nothing.
         """
-        pass
+    pass

Likely #144 plays a part here with regards the docstring text indentation.

Operating system: Linux
Python version: 3.6
Black version: 18.9b0
Does also happen on master: yes

@JelleZijlstra
Copy link
Collaborator

This is because making this change would change the contents of the string, and Black avoids doing that. We could plausibly relax that restriction for docstrings, though, which could be covered by #144.

@minusf
Copy link

minusf commented Dec 12, 2018

i have different case for this:

white:

    return json.loads("""
        {
          ...
        }
    """)

black:

    return json.loads(
        """
        {
          ...
        }
    """
    )

But it's easy to fix manually and once I get used to this style, the corner case is gone...

@JelleZijlstra JelleZijlstra added the T: style What do we want Blackened code to look like? label May 5, 2019
@ambv
Copy link
Collaborator

ambv commented Mar 3, 2020

This will we solved as part of #144.

@ambv ambv closed this as completed Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: style What do we want Blackened code to look like?
Projects
None yet
Development

No branches or pull requests

4 participants