autopep8 automatically formats Python code to conform to the PEP 8 style guide.
Questions tagged [autopep8]
99 questions
39
votes
6 answers
Visual Studio code with PyLint and autoPep8: How can I avoid PyLint to complain about my line length?
I recently switched to Visual Studio Code and I have to say I love it so far.
I'm working on a Python project, which includes the pip packages pylint and autopep8 and I configured VSCode to format the code according to these packages.
Only problem…

J. Hesters
- 13,117
- 31
- 133
- 249
38
votes
2 answers
Allow statements before imports with Visual Studio Code and autopep8
I'm using Visual Studio Code with the Python plugin and autopep8 with:
"editor.formatOnSave": true
I have local packages I need to import, so I have something like:
import sys
sys.path.insert(0, '/path/to/packages')
import localpackage
but when I…

waspinator
- 6,464
- 11
- 52
- 78
35
votes
4 answers
VS Code Python autopep8 does not honor 2 spaces hanging indentation
I'm trying to get autopep8 work to properly indent Python code with 2 spaces instead of 4. I'm using VS Code with Python extension which uses autopep8 for formatting. I found here that autopep8 can be configured to use 2 spaces…

Logan Yang
- 2,364
- 6
- 27
- 43
19
votes
3 answers
Python AutoPep8 formatting not working with max line length parameter
I noticed one strange thing that autopep8 autoformatting in VSCode doesn't work when we set
"python.formatting.autopep8Args": [
"--line-length 119"
],
But if this setting is in a default mode that is line length 79 then it works…

Mohit Kumar
- 533
- 1
- 4
- 11
17
votes
1 answer
How to avoid python autopep8 formatting in a line in VSCode?
I have a problem with the name of a var in a python file, using VSCode and autopep8, this is an example:
...
formal_education: bool
...
Autopep formater change the format like this:
...
formal_education:
bool
...
Raising a SyntaxError detected…

Juan Antonio
- 2,451
- 3
- 24
- 34
16
votes
3 answers
How to make pylint, flake8 or pycodestyle to automatically correct errors?
I have properly installed all of the aforementioned modules on a VM I use on Ubuntu 18.04. When running either of them on a specific script or folder, they do correctly identify style errors and output them in the console. E.g.:
(venv) .../src$…

Jan
- 264
- 1
- 5
- 14
13
votes
3 answers
Auto-PEP8 is adding lines by turning my lambda into def function, how do I disable this specific auto format?
I am using Visual Studio Code and PEP8 is automatically formatting a part of my code, I was just learning about lambdas and I had a 3 line code like this:
It went from this 3 line code:
# Lambda example
divide = lambda x, y: x/y
print(divide(10,…

Jsh0s
- 519
- 1
- 8
- 18
12
votes
1 answer
Error: spawn pycodestyle ENOENT
I got this error having linter-pep8 installed.
Error: spawn pycodestyle ENOENT
at exports._errnoException (util.js:1026:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:359:16)
at…

Lukasz Dynowski
- 11,169
- 9
- 81
- 124
9
votes
3 answers
How do you format python code in Visual Studio Code?
Opened a ticket with AutoPep8, but when I installed the autopep8 extension, it doesn't seem to find the module. When I change the config to tell it where it is a format doesn't do anything. Formating in terminal does however. Any ideas?…

Dan Quackenbush
- 123
- 1
- 1
- 6
8
votes
2 answers
Visual Studio Code and Autopep8 Formatter
I am trying to setup my python formatter to autopep8. It is installed properly, however it never as a formatting option in VSCode.
"python.formatting.autopep8Path":…

DawsonMSchaffer
- 119
- 1
- 2
- 8
8
votes
1 answer
Add autopep8 and linting to jupyter in VS code python notebook
Question
Error highlighting and autoformatting can be great tools to help one create great notebooks. I am trying to change the settings on the VS code to allow me to autoformat to pep8 in my python notebooks.
On this page for Jupiter notebooks have…

user4933
- 1,485
- 3
- 24
- 42
8
votes
1 answer
How can I make pylint and autopep8 agree on how to indent wrapped function definitions?
How can I make the prettifier autopep8 and the linter pylint agree on how to indent my code, without disabling indentation formatting/linting altogether? I don't mind that much if it's the first or the second formatting, as long as I can hit Alt+F…

Jan Aagaard
- 10,940
- 8
- 45
- 80
7
votes
1 answer
Can Black be configured to ignore imports?
I am switching over to using Black for all my Python projects from now on. Till now I had been using autopep8 as my auto-formatter and isort to sort my imports. But while using Black I found out that Black alone does the job of isort too alongside…

Arafat Khan
- 777
- 1
- 10
- 24
6
votes
2 answers
How to prevent PyDev's autopep8 import formatter from moving site.addsitedir() calls?
The Eclipse PyDev plugin includes fantastic integrated autopep8 support. It formats the code to PEP8 style automatically on save, with several knobs and options to tailor it to your needs.
But the autopep8 import formatter breaks site.addsitedir()…

CivFan
- 13,560
- 9
- 41
- 58
5
votes
3 answers
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:
Reinstall Virtual Studio Code
Reinstall Python 3.8
Computer Reboot
Using other formatters like…

Jakkalsie
- 53
- 3