Skip to content

Black changes quotes for multiline docstring when string normalization is off #1831

@ableeck

Description

@ableeck

Describe the bug A clear and concise description of what the bug is.
Black changes docstring quotes from ''' to """ for multiline docstrings when using --skip-string-normalization

To Reproduce Steps to reproduce the behavior:

  1. Take this file:
def a():
    '''The function a'''
    return 'a'


def b():
    '''
    The function b requires more words in the docstring
    and as such uses a slightly different format.
    '''
    return 'b'


def c():
    '''The function c requires more words in the docstring
    but lines are expensive.'''
    return 'c'


def d():
    '''
    The function d requires more words in the docstring
    and does not know how to be consistent.'''
    return 'd'


def e():
    '''The function e requires more words in the docstring
    and is confused by d.
    '''
    return 'e'
  1. Run Black on it with these arguments '--skip-string-normalization'
  2. The file is changed to this:
def a():
    '''The function a'''
    return 'a'


def b():
    """
    The function b requires more words in the docstring
    and as such uses a slightly different format.
    """
    return 'b'


def c():
    """The function c requires more words in the docstring
    but lines are expensive."""
    return 'c'


def d():
    """
    The function d requires more words in the docstring
    and does not know how to be consistent."""
    return 'd'


def e():
    """The function e requires more words in the docstring
    and is confused by d.
    """
    return 'e'

Expected behavior A clear and concise description of what you expected to happen.
Without string normalization the file should not have changed.

Environment (please complete the following information):

  • Version: black, version 20.8b1
  • OS and Python version: macOS 10.15.7 (19H2), Python 3.8.5

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

This does not appear to happen on master
https://black.now.sh/?version=master&state=_Td6WFoAAATm1rRGAgAhARYAAAB0L-Wj4AKjAQ1dAD2IimZxl1N_WlbvK5V8G17R4xukEnnG24eYaVqsO9_6tSjrhK5f5WKf_g-OgjsWb0kK-MvtSpgkdzgJLnzYS4f3GY8OH5albvMnG4cGqUn78eDpmdJkduL4YXMUDi12yq5JIscIt2bfAnZsT6hq_z11rTTphQqXwk5xVyfOL1nIpSjz4FKnsKm2HXad1K0KlzCEknnPI4UFeU5TJov_XipAaVlDfWw34P6rs24nQBo4c6rN12BSCcrgA-dNpdzPZQrPfac2I3B6M76TDzOozrhoqEI4Gr-Z8z4urccOOBRcysQyAE814q3fPeokrnE7vYZYZDBJcU6j9qDxQvBnEjQml9FyJWBWGWQ0EdcAAAAAALNBAnYfV9tzAAGpAqQFAAAii0RDscRn-wIAAAAABFla

Additional context Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    F: 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