Running PEP8 with Python

I cannot run PEP8 checks with a Python script.

I do not want to explicitly run pep8.exe, because I want to automate these checks, and the pep8 executable can be in different places on different platforms.

+5
source share
1 answer

Expanded use of PEP8 includes the use of pep8 inside a 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).") 
+6
source

Source: https://habr.com/ru/post/1215736/


All Articles