Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can flake8 *fix* my python whitespace problems?

Tags:

python

flake8

I just learned about flake8, which calls itself "Flake8: Your Tool For Style Guide Enforcement." While flake8 will find many Python whitespace errors and enforce PEP8, it does not appear to have an option to automatically fix problematic python code.

autopep8 does appear to have this option (called --in-place), but flake8 seems to have much wider support.

Is there a way to make flake8 fix my code?

like image 568
vy32 Avatar asked Mar 02 '23 08:03

vy32


1 Answers

no, flake8 is a linter only -- that is, it only checks your code. (technically, flake8 doesn't even check your code -- it is just a framework for other linters to plug into and provides inclusion / exclusion / etc. on top of other tools)

if you want something which fixes your code, you'll want a code formatter to do code formatting (such as autopep8 / add-trailing-comma / yapf / black / etc.)

like image 135
Anthony Sottile Avatar answered Mar 18 '23 10:03

Anthony Sottile