fix: resolve flake8 errors in sanity_check_repo function

This commit is contained in:
Paul Gauthier (aider) 2024-08-30 07:55:49 -07:00
parent 4c32e45b74
commit ae1508582c

View file

@ -294,28 +294,26 @@ def register_litellm_models(git_root, model_metadata_fname, io, verbose=False):
return 1 return 1
def sanity_check_repo(repo): def sanity_check_repo(repo, io):
if not repo: if not repo:
return True return True
try: try:
repo.get_tracked_files() repo.get_tracked_files()
return True return True
except UnableToCountRepoFiles as e: except UnableToCountRepoFiles as exc:
pass error_msg = str(exc)
error_msg = str(e) if "version in (1, 2)" in error_msg:
io.tool_error("Aider only works with git repos with version number 1 or 2.")
io.tool_error("You may be able to convert your repo: git update-index --index-version=2")
io.tool_error("Or run aider --no-git to proceed without using git.")
io.tool_error("https://github.com/paul-gauthier/aider/issues/211")
return False
if "version in (1, 2)" in error_msg: io.tool_error("Unable to read git repository, it may be corrupt?")
io.tool_error("Aider only works with git repos with version number 1 or 2.") io.tool_error(error_msg)
io.tool_error("You may be able to convert your repo: git update-index --index-version=2") return False
io.tool_error("Or run aider --no-git to proceed without using git.")
io.tool_error("https://github.com/paul-gauthier/aider/issues/211")
return
io.tool_error("Unable to read git repository, it may be corrupt?")
io.tool_error(error_msg)
return
def main(argv=None, input=None, output=None, force_git_root=None, return_coder=False): def main(argv=None, input=None, output=None, force_git_root=None, return_coder=False):
@ -528,7 +526,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
except FileNotFoundError: except FileNotFoundError:
pass pass
if not sanity_check_repo(repo): if not sanity_check_repo(repo, io):
return 1 return 1
commands = Commands(io, None, verify_ssl=args.verify_ssl, args=args, parser=parser) commands = Commands(io, None, verify_ssl=args.verify_ssl, args=args, parser=parser)