How do I enable auto code formatting for flake8 in PyCharm How do I enable auto code formatting for flake8 in PyCharm python python

How do I enable auto code formatting for flake8 in PyCharm


Flake8 and import ordering are not auto-fixable in a way that complies with what you're seeing. You can auto-fix pep8 with autopep8.

There are discussions here about implementing this for Flake8 though.


For automatically sorting import statements use isort. Consider using black to auto-format your Python code.


The tool you want is probably autopep8. This is especially because the warning codes it uses correspond to the flake8 ones.

For example, if you want to autofix all instances of E701 multiple statements on a single line warning, run the following

for f in `find -name "*.py"`; do autopep8 --in-place --select=E701 $f; done