-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
PEP8: Dictionary values should have an extra indent #113
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,6 +121,51 @@ Optional:: | |
var_one, var_two, | ||
var_three, var_four) | ||
|
||
For dictionaries there is an extra rule. When placing a dictionary key on a new | ||
line an additional hanging indent should be added. This is so it is easy to | ||
differentiate between keys and values. | ||
|
||
Yes:: | ||
|
||
# Keys aligned with opening delimiter, values have an extra indent. | ||
mydict = {'firstkey': | ||
'a very very very very very long value', | ||
'secondkey': 'a short value', | ||
'thirdkey': 'a very very very' | ||
' long value that continues on the next line' | ||
' and even on the line after that.', | ||
} | ||
|
||
# Keys with one and values with two levels of hanging indents. | ||
mydict = { | ||
'firstkey': | ||
'a very very very very very long value', | ||
'secondkey': 'a short value', | ||
'thirdkey': 'a very very very' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to share what other IDE is already doing with respect to this issue. PyCharm will automatically do this for you
And this too
But it will not do this one, which is being considered as a 'yes' in this proposal.
Perhaps something to take into account when making decision about this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the option is not done by pycharm the least as well, but I didn't want to make the change to opinionated. |
||
' long value that continues on the next line' | ||
' and even on the line after that.', | ||
} | ||
|
||
# Continuing value indented to column where the value starts. | ||
mydict = { | ||
'thirdkey': 'a very very very' | ||
' long value that continues on the next line' | ||
' and even on the line after that.', | ||
} | ||
|
||
|
||
No:: | ||
|
||
# Keys and values indented in the same way. | ||
mydict = {'firstkey': | ||
'a very very very very very long value', | ||
'secondkey': 'a short value', | ||
'thirdkey': 'a very very very' | ||
' long value that continues on the next line', | ||
' and even on the line after that.' | ||
} | ||
|
||
|
||
.. _`multiline if-statements`: | ||
|
||
When the conditional part of an ``if``-statement is long enough to require | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpicky 😅 there should be a comma
For dictionaries, there is ...
... on a new line, an additional ...