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

Indent of redbaron docstrings leaves trailing white spaces #224

Open
JohannesBuchner opened this issue Nov 19, 2024 · 0 comments
Open

Indent of redbaron docstrings leaves trailing white spaces #224

JohannesBuchner opened this issue Nov 19, 2024 · 0 comments

Comments

@JohannesBuchner
Copy link

Adding a docstring adds indent, including on empty lines.

I am analysing and altering example.py:

def indicator(r, threshold=42):
    if r > threshold:
        return False
    else:
        return True

with the following code

import redbaron
rb = redbaron.RedBaron(open('gendocstr/example2.py').read())
docstring = """Hello world

how is it going?
"""
rb[0].value.insert(0, '"""%s"""' % docstring)
print(rb.dumps())

gives:

def indicator(r, threshold=42):
    """Hello world
    
    how is it going?
    """
    if r > threshold:
        return False
    else:
        return True

The line in the middle is also indented.

This causes linters to complain about trailing newlines.

As far as I can see, there is no way to control the automatic indentation.

This is with redbaron 0.9.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant