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 Off with Multi-Line Strings #1179

Closed
bwendling opened this issue Nov 28, 2016 · 2 comments
Closed

Indentation Off with Multi-Line Strings #1179

bwendling opened this issue Nov 28, 2016 · 2 comments
Labels
Enhancement ✨ Improvement to a component

Comments

@bwendling
Copy link

When pylint calculates the correct indentation of a line following a multi-line string it uses the last non-space character in the multi-line string rather than basing it off of the code preceding the string. In the following example, I would expect the indentation of some and string to be four spaces, because that's the correct indentation based off of the _ = """Dear Guido, line. But pylint wants it to be four spaces beyond the start of Bill""", which makes the code less readable IMO.

Steps to reproduce

1. cat > /tmp/z.py
_ = """Dear Guido,

Python is pretty awesome, but there's something annoying with the linter.

                                 Sincerely,
                                 Bill""".format(
    some=variable_with_a_long_name,
    strings=another_variable_with_a_really_long_name)
2. pylint /tmp/z.py

Current behavior

Outputs the following message:

************* Module z
C:  7, 0: Wrong hanging indentation (add 33 spaces).
    some=variable_with_a_long_name,
    ^                                | (bad-continuation)
C:  8, 0: Wrong hanging indentation (add 33 spaces).
    strings=another_variable_with_a_really_long_name)
    ^                                | (bad-continuation)

Expected behavior

This should have been acceptable.

pylint --version output

$ pylint --version
pylint 2.0.0, 
astroid 1.5.0
Python 3.5.0 (default, Nov 18 2015, 12:09:02) 
[GCC 4.8.4]
@PCManticore
Copy link
Contributor

Sounds like a good improvement, thanks.

@Pierre-Sassoulas
Copy link
Member

bad-continuation has been removed in #3571, black or another formatter can help you with this better than Pylint

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

No branches or pull requests

3 participants