I can not run PEP8 checks from a Python script.
I don't want explicitly run pep8.exe, because I want to automate this checks, and pep8 executable can lay in different places on different platforms.
Pylint: looks for errors, enforces a coding standard that is close to PEP8, and even offers simple refactoring suggestions. Flake8: wrapper around PyFlakes, pycodestyle and McCabe; this will check Python source code for errors and violations of some of the PEP8 style conventions.
So, as you can see, PyCharm supports PEP8 as the official Python style guide. If you explore the list of inspections ( Ctrl+Alt+S - Inspections), you will see that PyCharm launches the pep8.py tool on your code, and pinpoints the code style violations.
Using autopep8autopep8 --in-place --aggressive --aggressive --recursive . Once done, if you use pycodestyle to check your code again, most warnings should be gone, but most likely not all of them, some you might need to fix manually. pycodestyle . So there you have it, your code should now comply with PEP 8!
PEP8 advanced usage covers using pep8 inside Python script.
Quoting an example:
import unittest
import pep8
class TestCodeFormat(unittest.TestCase):
def test_pep8_conformance(self):
"""Test that we conform to PEP8."""
pep8style = pep8.StyleGuide(quiet=True)
result = pep8style.check_files(['file1.py', 'file2.py'])
self.assertEqual(result.total_errors, 0,
"Found code style errors (and warnings).")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With