@Andy Hayden gave good overview of autopep8. In addition to that there is one more package called pep8ify which also does the same thing.
However both packages can remove only lint errors but they cannot format code.
little = more[3: 5]
Above code remains same after pep8ifying also. But the code doesn't look good yet. You can use formatters like yapf, which will format the code even if the code is PEP8 compliant.
Above code will be formatted to
little = more[3:5]
Some times this even destroys Your manual formatting. For example
BAZ = {
[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12]
}
will be converted to
BAZ = {[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]}
But You can tell it to ignore some parts.
BAZ = {
[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12]
} # yapf: disable
Taken from my old blog post: Automatically PEP8 & Format Your Python Code!