-
Notifications
You must be signed in to change notification settings - Fork 69
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 dictionary values on a new line extra #61
base: master
Are you sure you want to change the base?
Conversation
indent/python.vim
Outdated
let res = base + s:sw() * 2 | ||
endif | ||
|
||
" If a colon is the final charactar on previous line |
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.
s/charactar/character/
Also mention that this is for dicts here?
I like it. Do you have some reference, e.g. is it mentioned in PEP8? Current behavior:
|
I'm not sure about PEP 8, but
|
@blueyed, I like it as well, so much in fact that I assumed it would be allowed by PEP8. But as @myint notes it is indeed marked as wrong by pycodestyle. Looking at PEP8 itself it is not special cased and not even allowed. Because I think this indentation is much clearer I just sent the following to the python-ideas mailinglist: I have an idea to improve indenting guidelines for dictionaries for better readability: If a value in a dictionary literal is placed on a new line, it should have (or at least be allowed to have) a n additional hanging indent. Below is an example: mydict = {'mykey':
'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',
} As opposed to this IMHO much less readable version: mydict = {'mykey':
'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',
} As you can see it is much harder in the second version to distinguish between keys and values. |
be5bd7d
to
42b2305
Compare
For reference: Guido likes it: https://mail.python.org/pipermail/python-ideas/2016-October/042754.html. |
I made a pull request in the peps repo: python/peps#113 |
42b2305
to
d19b456
Compare
Codecov Report
@@ Coverage Diff @@
## master #61 +/- ##
==========================================
+ Coverage 92.75% 92.82% +0.06%
==========================================
Files 1 1
Lines 207 209 +2
==========================================
+ Hits 192 194 +2
Misses 15 15
Continue to review full report at Codecov.
|
I've rebased this. We might add a configuration variable for it though, since it will trigger flake8/pycodestyle's E127, which might be annoying. I've created PyCQA/pycodestyle#785 to ask for relaxation of this in pycodestyle itself. |
This indents dictionaries in the following way: