Wemake-python-styleguide: Forbid to have empty lines before and after the brackets

Created on 7 Oct 2019  路  7Comments  路  Source: wemake-services/wemake-python-styleguide

Rule request

Thesis

Wrong

Currently it is possible to write code like this:

some_list = [
    1,
    2,
    3,

]
# Mind ^ the empty line before `]`

It shows that no violations are raised for this code (from our linter + dependencies).

We also have this code:

# Mind the empty line after the `[`
some_list = [

    1,
    2,
    3,
]

It should not be allowed for consistency reasons. I assume that we should use tokenize to check that.

Correct

But, there are exceptions:

some_list = [
    1,
    2,

    10,
    11,
]

Note that a single empty line between elements is allowed (between 2, and 10,)

Parens to check: [, (, {, ], ), }

Hacktoberfest help wanted starter pr-rejected rule request

All 7 comments

I can work on removing some empty lines. Is this across all documents or specific ones?

Hi, @lmonyelle! This is not about deleting empty lines. This is about creating a new linting rule to enforce python code consistency across our users' codebases.

@sobolevn I'd like to give it a try.

@QQ-88 you are welcome! Feel free to ask for help.

Had a look at the code @sobolevn, that's unfortunately above my skill level.

Ok, no problem!

I can give this one a try.

Was this page helpful?
0 / 5 - 0 ratings