diff --git a/aider/linter.py b/aider/linter.py index e463a77a6..0e2d89b75 100644 --- a/aider/linter.py +++ b/aider/linter.py @@ -1,20 +1,22 @@ import os -import tree_sitter import sys import warnings from pathlib import Path -from aider.dump import dump - +import tree_sitter from grep_ast import TreeContext, filename_to_lang +from aider.dump import dump + # tree_sitter is throwing a FutureWarning warnings.simplefilter("ignore", category=FutureWarning) from tree_sitter_languages import get_language, get_parser # noqa: E402 -def basic_lint(fname, code): +def basic_lint(fname, code): lang = filename_to_lang(fname) + if not lang: + return language = get_language(lang) parser = get_parser(lang) @@ -46,10 +48,11 @@ def basic_lint(fname, code): return output + # Traverse the tree to find errors and print context def traverse_tree(node): errors = [] - if node.type == 'ERROR' or node.is_missing: + if node.type == "ERROR" or node.is_missing: line_no = node.start_point[0] errors.append(line_no) @@ -58,6 +61,7 @@ def traverse_tree(node): return errors + def main(): """ Main function to parse files provided as command line arguments. @@ -72,5 +76,6 @@ def main(): if errors: print(errors) + if __name__ == "__main__": main()