Added a new command to run the linter on dirty files, fix problems, and then commit.

This commit is contained in:
Paul Gauthier 2024-05-18 18:35:33 -07:00
parent 7b8e603249
commit 04084883e8
4 changed files with 38 additions and 1 deletions

View file

@ -24,7 +24,8 @@ class Linter:
py_cmd = f"flake8 --select={fatal} --show-source" # noqa: F841
self.languages = dict(
python=self.py_lint,
# python=self.py_lint,
python="pre-commit run --files"
)
def set_linter(self, lang, cmd):
@ -41,8 +42,10 @@ class Linter:
cmd = cmd.split()
try:
subprocess.check_output(cmd, cwd=self.root).decode()
print("zero")
return # zero exit status
except subprocess.CalledProcessError as err:
print("non-zero")
return err.output.decode() # non-zero exit status
def lint(self, fname):