diff --git a/aider/args.py b/aider/args.py index 018e42ca6..0b8ed74d1 100644 --- a/aider/args.py +++ b/aider/args.py @@ -321,6 +321,7 @@ def get_parser(default_config_files, git_root): "--lint-cmd", action="append", help='Specify lint commands to run for different languages, eg: "python: flake8 --select=..." (can be used multiple times)', + default=[], ) diff --git a/aider/commands.py b/aider/commands.py index 7abd0a831..076d5dcf2 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -165,26 +165,28 @@ class Commands: return fnames = self.coder.repo.get_dirty_files() - - if fnames: - self.cmd_commit("") - + linted = False for fname in fnames: try: errors = self.coder.linter.lint(fname) + linted = True except FileNotFoundError as err: self.io.tool_error(f"Unable to lint {fname}") self.io.tool_error(str(err)) continue if errors: + # Commit everything before we start fixing lint errors + if self.coder.repo.is_dirty(): + self.cmd_commit("") + self.io.tool_error(errors) abs_file_path = self.coder.abs_root_path(fname) self.coder.abs_fnames.add(abs_file_path) self.coder.run(errors) - if self.coder.repo.is_dirty(): + if linted and self.coder.repo.is_dirty(): self.cmd_commit("") def cmd_clear(self, args):