wemake-python-styleguide
wemake-python-styleguide copied to clipboard
Brackets that come under each other should not pass
Bug report
What's wrong
Currently we allow brackets that located like so:
xy = [[
]
]
How is that should be
This should raise a violation. Correct code samples:
xy = [[]]
xy = [
[],
]
xy = [[
]]
It raises tests/fixtures/noqa.py:2:2: C812 missing trailing comma which is good enough.
And this example:
xy = [[
],
]
still should not be allowed.
This will be marked as a low priority. Since the algo to count parens like this is too complex. And the profit is not so big.
I cannot fight these corner cases:
x = [
[1], # note [ position
[2], # note [ position
]
This is a valid case. But, [ comes just under [
So, it is hard to tell the difference between these two cases.
To fix this we also need to count "level" of brackets. It is possible to nest brackets of the same level. But, not different levels.