diff --git a/aider/args.py b/aider/args.py index a528c78d0..a6d5bbe6a 100644 --- a/aider/args.py +++ b/aider/args.py @@ -313,7 +313,7 @@ def get_parser(default_config_files, git_root): group.add_argument( "--lint", action="store_true", - help="Run the linter on all dirty files, fix problems and commit", + help="Lint and fix provided files, or dirty files if none provided", default=False, ) group.add_argument( diff --git a/aider/commands.py b/aider/commands.py index 36d6ba626..affa5af5e 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -154,14 +154,14 @@ class Commands: self.coder.repo.commit(message=commit_message) def cmd_lint(self, args="", fnames=None): - "Commit, run the linter on all dirty files, fix problems and commit again" + "Lint and fix provided files or in-chat files if none provided" if not self.coder.repo: self.io.tool_error("No git repository found.") return if not fnames: - fnames = self.coder.repo.get_dirty_files() + fnames = self.coder.get_inchat_relative_files() if not fnames: self.io.tool_error("No dirty files to lint.") @@ -170,7 +170,7 @@ class Commands: lint_coder = None for fname in fnames: try: - errors = self.coder.linter.lint(fname, cmd=args) + errors = self.coder.linter.lint(fname) except FileNotFoundError as err: self.io.tool_error(f"Unable to lint {fname}") self.io.tool_error(str(err)) diff --git a/aider/linter.py b/aider/linter.py index b2e2fd2b4..f2afe2d05 100644 --- a/aider/linter.py +++ b/aider/linter.py @@ -1,9 +1,9 @@ import os +import re import subprocess import sys import traceback import warnings -import re from dataclasses import dataclass from pathlib import Path @@ -205,9 +205,6 @@ def traverse_tree(node): return errors -import re - - def find_filenames_and_linenums(text, fnames): """ Search text for all occurrences of :\\d+ and make a list of them