Comments (7)
Confirmed in master.
from yapf.
Interesting. Our version of pylint doesn't agree with PEP 8 on this. If I move the )
to align with the f
in foo
, it complains that it shouldn't be that way.
from yapf.
I think you're aware (not sure if you're talking pep8 the linter or pep8 the spec), but it seems pylint and pep8 the linter don't agree. Here's another example of yapf output:
TEST_LIST = ('foo', 'bar', # first comment
'baz', # second comment
)
This raises pep8 linter E124 "closing bracket does not match visual indentation". If I add another space to the last line, you instead get pylint C0330 "wrong continued indentation"!
The pep8 spec says the following: "The closing brace/bracket/parenthesis on multi-line constructs may either line up under the first non-whitespace character of the last line of list [example1] or it may be lined up under the first character of the line that starts the multi-line construct [example2]".
example1 shows this:
my_list = [
1, 2, 3,
4, 5, 6,
]
example2 (not relevant to this discussion really, just included for completeness):
my_list = [
1, 2, 3,
4, 5, 6,
]
It seems pylint & yapf are wrong, in this case. The pep8 linter error is correct.
from yapf.
I think the test testClosingBracketIndent in reformatter_test.py is wrong, it claims this is correct layout:
while (xxxxxxxxxxxxxxxxxxxxx(yyyyyyyyyyyyy[zzzzz]) == 'aaaaaaaaaaa' and
xxxxxxxxxxxxxxxxxxxxx(yyyyyyyyyyyyy[zzzzz].aaaaaaaa[0]) == 'bbbbbbb'
):
from yapf.
@alexjurkiewicz It seems like this is a conflict between Google's version and PEP 8. I'll need to add a knob to control this...
from yapf.
I added 9439278. Let's see if that fixes this for you.
from yapf.
Beaut! Thanks @gwelymernans 👍
from yapf.
Related Issues (20)
- Improve error reporting when `yapf` encounters unsupported Python syntax
- Set specific options for keywords
- Function call without arguments.
- Yapf not formatting python generic HOT 1
- dedent_closing_brackets not working for Annotations[]
- yapf is failing `pre-commit` with `tool.yapfignore` configured: `yapf: input filenames did not match any python files`
- [BUG] yapf with split_all_top_level_comma_separated_values set to true fails to split lines with tuple LHS HOT 1
- [Bug] [Crash][Reproducible] `EOFError: Ran out of input` when import yapf with multiprocess
- assert formatting
- Strange inconsistent behaviour HOT 3
- Is there a each_dict_entry_on_separate_line for lists? HOT 2
- Try to keep list literals in tuples aligned
- yapf-diff inconsistent with yapf on multiline strings with backslashes
- Ternary conditionals within F Strings Raise IndexError
- Split type hints with trailing comma
- yapf adds spaces before backslash with every run
- Split first and only argument into separate line
- The formatter fails in this file
- Is there a way to `ALLOW_MULTILINE_LISTS`? HOT 1
- Do not put dict value on the next line
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yapf.