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

Support visual indent of continuation lines after with/assert/raise. #912

Merged
merged 1 commit into from
Mar 23, 2020

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Feb 25, 2020

"with" is likely the most common case, and this indentation is
explicitly given as example by PEP8 (under "maximum line length").

Closes #569.

print('foo')
with open('/path/to/some/file/you/want/to/read') as file_1, \
open('/path/to/some/file/being/written', 'w') as file_2:
file_2.write(file_1.read())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

none of these three align properly -- they should produce an error I believe?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they do.
not sure I understand the syntax of the test file actually... I added #: E127:4:... and looks like tests pass
(the error is produced when manually testing as well)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😕 weird! I'll look into why that is and fix that up 👍

Copy link
Member

@asottile asottile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FichteFoll
Copy link
Contributor

Does it work for more than one line continuation as well?

"with" is likely the most common case, and this indentation is
explicitly given as example by PEP8 (under "maximum line length").
@anntzer
Copy link
Contributor Author

anntzer commented Feb 26, 2020

Yes, added tests for that.

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

Successfully merging this pull request may close these issues.

E127 on slightly modified PEP-8 approved example (multiline with)
3 participants