wemake-python-styleguide icon indicating copy to clipboard operation
wemake-python-styleguide copied to clipboard

Brackets that come under each other should not pass

Open sobolevn opened this issue 7 years ago • 4 comments

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 = [[
]]

sobolevn avatar Dec 06 '18 10:12 sobolevn

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.

sobolevn avatar Dec 14 '18 06:12 sobolevn

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.

sobolevn avatar Dec 14 '18 06:12 sobolevn

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.

sobolevn avatar Nov 04 '19 23:11 sobolevn

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.

sobolevn avatar Nov 05 '19 08:11 sobolevn