mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 02:05:00 +00:00
aider is AI pair programming in your terminal
https://aider.chat/
![]() # Context: USER: unroll the list comprehension so we can try/catch the exception below which is thrown for files not in any git repo File "/Users/gauthier/Projects/aider/aider/coder.py", line 68, in <genexpr> git.Repo(fname, search_parent_directories=True).git_dir ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gauthier/tmp/try-aider/.venv/lib/python3.11/site-packages/git/repo/base.py", line 265, in __init__ raise InvalidGitRepositoryError(epath) git.exc.InvalidGitRepositoryError: /Users/gauthier/tmp/try-aider/tmp.py ASSISTANT: To unroll the list comprehension and handle the exception, we can replace it with a for loop and use try-except to catch the `InvalidGitRepositoryError`. ```python aider/coder.py <<<<<<< ORIGINAL repo_paths = list( git.Repo(fname, search_parent_directories=True).git_dir for fname in self.fnames ) ======= repo_paths = [] for fname in self.fnames: try: repo_path = git.Repo(fname, search_parent_directories=True).git_dir repo_paths.append(repo_path) except git.exc.InvalidGitRepositoryError: pass >>>>>>> UPDATED ``` This change will catch the `InvalidGitRepositoryError` and continue processing the remaining files. |
||
---|---|---|
aider | ||
.flake8 | ||
.pre-commit-config.yaml | ||
requirements.txt | ||
setup.py |