I want to check a file using pycodestyle
. I've tried using what their docs say:
import pycodestyle
fchecker = pycodestyle.Checker('testsuite/E27.py')
file_errors = fchecker.check_all()
# I took off the show_source=True and the final print
It prints the errors, but file_errors
is the NUMBER of errors, not the errors themselves. I want the errors to be returned in a list. How can I do that using pycodestyle?
More details
pycodestyle
is a module that checks code against the PEP8 guidelines. Usually, it is used with the command line, but I want to automate it by putting it into a script. Using the docs, you get:
import pycodestyle
fchecker = pycodestyle.Checker('testsuite/E27.py', show_source=True)
file_errors = fchecker.check_all()
print("Found %s errors (and warnings)" % file_errors)
This prints the errors and the total amount of errors. However, file_errors
is not a list- it's the number of errors.
I would want a way to get a list from pycodestyle.Checker
(or any thing in pycodestyle). How can I do that?
What I've done: I've looked on google, and skimmed pycodestyle
's docs, but nothing is mentioned.