Skip to content

Docstrings reformatted to be too long #1632

@mlissner

Description

@mlissner

Describe the bug When there's a docstring that's near the max line length with the """ on the next line, the new version of Black moves the """ to the first line, making the line too long.

To Reproduce Steps to reproduce the behavior:

  1. Create a file with this content:

    def my_func():
            """Remove punctuation and return cleaned string plus its length in tokens.
            """
            pass
    
  2. Reformat it

  3. Note that it now has the docstring on one line and that that line has 82 chars:

    def my_func():
            """Remove punctuation and return cleaned string plus its length in tokens."""
            pass
    

Expected behavior

The docstring shouldn't get wrapped.

Environment (please complete the following information):

  • Version: [e.g. master] 20.8b1

  • OS and Python version:
    Linux/Python 3.8.2

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

Yes: https://black.now.sh/?version=master&state=_Td6WFoAAATm1rRGAgAhARYAAAB0L-Wj4AC3AIldAD2IimZxl1N_WlbvK5V-ga8lyrVzgK48mW1g5y7ZvjbGhEN7nG-8hLA9oQ3I4FUxivNyD3Gy0_4fbH0Mg7-k28ZpTZzLozFMvMFSuDJT_0ZQmFpNZw6AAvoHjtKEQjGQksHXW1WBInIzl_HhTgRlCs-04wcVCEBY4OInuM5XhKBPO4ZIAzTqLcpeAAAAADHge2pSp2OmAAGlAbgBAAByceBuscRn-wIAAAAABFla

Metadata

Metadata

Assignees

No one assigned

    Labels

    F: linetoolongBlack makes our lines too longF: stringsRelated to our handling of stringsT: bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions