mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-28 16:25:00 +00:00
Merge pull request #1216 from akaihola/misc-cleanups
Clean up types and drop an unused variable
This commit is contained in:
commit
59cb457008
3 changed files with 11 additions and 14 deletions
|
@ -111,9 +111,9 @@ class EditBlockFunctionCoder(Coder):
|
|||
updated = get_arg(edit, "updated_lines")
|
||||
|
||||
# gpt-3.5 returns lists even when instructed to return a string!
|
||||
if self.code_format == "list" or type(original) == list:
|
||||
if self.code_format == "list" or type(original) is list:
|
||||
original = "\n".join(original)
|
||||
if self.code_format == "list" or type(updated) == list:
|
||||
if self.code_format == "list" or type(updated) is list:
|
||||
updated = "\n".join(updated)
|
||||
|
||||
if original and not original.endswith("\n"):
|
||||
|
|
|
@ -529,7 +529,9 @@ class Commands:
|
|||
# Handle absolute paths
|
||||
raw_matched_files = [Path(pattern)]
|
||||
else:
|
||||
raw_matched_files = list(Path(self.coder.root).glob(pattern))
|
||||
raw_matched_files = list(
|
||||
Path(self.coder.root).glob(pattern)
|
||||
)
|
||||
except ValueError as err:
|
||||
self.io.tool_error(f"Error matching {pattern}: {err}")
|
||||
raw_matched_files = []
|
||||
|
@ -539,9 +541,9 @@ class Commands:
|
|||
matched_files += expand_subdir(fn)
|
||||
|
||||
matched_files = [
|
||||
str(Path(fn).relative_to(self.coder.root))
|
||||
fn.relative_to(self.coder.root)
|
||||
for fn in matched_files
|
||||
if Path(fn).is_relative_to(self.coder.root)
|
||||
if fn.is_relative_to(self.coder.root)
|
||||
]
|
||||
|
||||
# if repo, filter against it
|
||||
|
@ -555,8 +557,6 @@ class Commands:
|
|||
def cmd_add(self, args):
|
||||
"Add files to the chat so aider can edit them or review them in detail"
|
||||
|
||||
added_fnames = []
|
||||
|
||||
all_matched_files = set()
|
||||
|
||||
filenames = parse_quoted_filenames(args)
|
||||
|
@ -618,7 +618,6 @@ class Commands:
|
|||
self.io.tool_output(
|
||||
f"Moved {matched_file} from read-only to editable files in the chat"
|
||||
)
|
||||
added_fnames.append(matched_file)
|
||||
else:
|
||||
self.io.tool_error(
|
||||
f"Cannot add {matched_file} as it's not part of the repository"
|
||||
|
@ -637,7 +636,6 @@ class Commands:
|
|||
self.coder.abs_fnames.add(abs_file_path)
|
||||
self.io.tool_output(f"Added {matched_file} to the chat")
|
||||
self.coder.check_added_files()
|
||||
added_fnames.append(matched_file)
|
||||
|
||||
def completions_drop(self):
|
||||
files = self.coder.get_inchat_relative_files()
|
||||
|
@ -1081,7 +1079,6 @@ class Commands:
|
|||
|
||||
|
||||
def expand_subdir(file_path):
|
||||
file_path = Path(file_path)
|
||||
if file_path.is_file():
|
||||
yield file_path
|
||||
return
|
||||
|
@ -1089,7 +1086,7 @@ def expand_subdir(file_path):
|
|||
if file_path.is_dir():
|
||||
for file in file_path.rglob("*"):
|
||||
if file.is_file():
|
||||
yield str(file)
|
||||
yield file
|
||||
|
||||
|
||||
def parse_quoted_filenames(args):
|
||||
|
|
|
@ -18,7 +18,7 @@ class TestUtils(unittest.TestCase):
|
|||
|
||||
def test_find_filename(self):
|
||||
fence = ("```", "```")
|
||||
valid_fnames = ["file1.py", "file2.py", "dir/file3.py", "\windows\__init__.py"]
|
||||
valid_fnames = ["file1.py", "file2.py", "dir/file3.py", r"\windows\__init__.py"]
|
||||
|
||||
# Test with filename on a single line
|
||||
lines = ["file1.py", "```"]
|
||||
|
@ -45,8 +45,8 @@ class TestUtils(unittest.TestCase):
|
|||
self.assertEqual(eb.find_filename(lines, fence, valid_fnames), "file1.py")
|
||||
|
||||
# Test with fuzzy matching
|
||||
lines = ["\windows__init__.py", "```"]
|
||||
self.assertEqual(eb.find_filename(lines, fence, valid_fnames), "\windows\__init__.py")
|
||||
lines = [r"\windows__init__.py", "```"]
|
||||
self.assertEqual(eb.find_filename(lines, fence, valid_fnames), r"\windows\__init__.py")
|
||||
|
||||
# fuzzy logic disabled v0.11.2-dev
|
||||
def __test_replace_most_similar_chunk(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue