Jakkalsie
Jakkalsie

Reputation: 73

Why does VS-Code Autopep8 format 2 white lines?

print("Hello")

def world():
    print("Hello")

world()

Gets corrected to:

print("Hello")


def world():
    print("Hello")


world()

I have tried to:

Upvotes: 7

Views: 3043

Answers (3)

MutantMahesh
MutantMahesh

Reputation: 1748

you can also configure python.formatting.autopep8Args under your vscode setting.

python.formatting.autopep8Args

Upvotes: 0

Lucian Tarbă
Lucian Tarbă

Reputation: 111

You can disable this by using the following configuration in your .vscode/settings.json

{
    "python.formatting.provider": "autopep8",
    "python.formatting.autopep8Args": [
        "--ignore=E302"
    ]
}

Here are all the autopep8 features explained: https://github.com/hhatto/autopep8#features

Upvotes: 8

DeepSpace
DeepSpace

Reputation: 81684

Because autopep8 follows PEP8 which suggests 2 blank lines around top-level functions.

Surround top-level function and class definitions with two blank lines.

Upvotes: 5

Related Questions