mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 10:14:59 +00:00
aider: Remove unused imports and variable in aider/linter.py
to pass pre-commit hooks.
# Aider chat conversation: USER: I ran this command: .git/hooks/pre-commit And got this output: [WARNING] Unstaged files detected. [INFO] Stashing unstaged files to /Users/gauthier/.cache/pre-commit/patch1715981257-12950. isort....................................................................Failed - hook id: isort - files were modified by this hook Fixing /Users/gauthier/Projects/aider/aider/linter.py black....................................................................Failed - hook id: black - files were modified by this hook reformatted aider/linter.py All done! ✨ 🍰 ✨ 1 file reformatted. flake8...................................................................Failed - hook id: flake8 - exit code: 1 aider/linter.py:1:1: F401 'os' imported but unused import os ^ aider/linter.py:6:1: F401 'tree_sitter' imported but unused import tree_sitter ^ aider/linter.py:9:1: F401 'aider.dump.dump' imported but unused from aider.dump import dump ^ aider/linter.py:21:5: F841 local variable 'language' is assigned to but never used language = get_language(lang) ^ [WARNING] Stashed changes conflicted with hook auto-fixes... Rolling back fixes... [INFO] Restored changes from /Users/gauthier/.cache/pre-commit/patch1715981257-12950. ASSISTANT: Please add `aider/linter.py` to the chat so I can make the necessary changes to fix the issues reported by the pre-commit hooks. USER: I added these files to the chat: aider/linter.py ASSISTANT: To fix the issues reported by the pre-commit hooks, we need to: 1. Remove unused imports: `os`, `tree_sitter`, and `dump`. 2. Remove the unused variable `language`. Here are the *SEARCH/REPLACE* blocks: aider/linter.py ```python <<<<<<< SEARCH import os import sys import warnings from pathlib import Path import tree_sitter from grep_ast import TreeContext, filename_to_lang from aider.dump import dump ======= import sys import warnings from pathlib import Path from grep_ast import TreeContext, filename_to_lang >>>>>>> REPLACE ``` aider/linter.py ```python <<<<<<< SEARCH language = get_language(lang) ======= >>>>>>> REPLACE ``` Now, the file should pass the pre-commit hooks.
This commit is contained in:
parent
494aa0140b
commit
a9fd02c74d
1 changed files with 0 additions and 5 deletions
|
@ -1,13 +1,9 @@
|
|||
import os
|
||||
import sys
|
||||
import warnings
|
||||
from pathlib import Path
|
||||
|
||||
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
|
||||
|
@ -18,7 +14,6 @@ def basic_lint(fname, code):
|
|||
if not lang:
|
||||
return
|
||||
|
||||
language = get_language(lang)
|
||||
parser = get_parser(lang)
|
||||
|
||||
tree = parser.parse(bytes(code, "utf-8"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue