diff --git a/aider/coders/editblock_func_coder.py b/aider/coders/editblock_func_coder.py index 42bbb20f359..27aa53f115c 100644 --- a/aider/coders/editblock_func_coder.py +++ b/aider/coders/editblock_func_coder.py @@ -111,9 +111,9 @@ def _update_files(self): 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"): diff --git a/aider/commands.py b/aider/commands.py index 466332150c5..7a73f531117 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -529,7 +529,9 @@ def glob_filtered_to_repo(self, pattern): # 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 @@ def glob_filtered_to_repo(self, pattern): 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 @@ def glob_filtered_to_repo(self, pattern): 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 @@ def cmd_add(self, args): 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 @@ def cmd_add(self, args): 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 @@ def cmd_settings(self, args): 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): diff --git a/tests/basic/test_editblock.py b/tests/basic/test_editblock.py index 61d3c8668d0..037333b5922 100644 --- a/tests/basic/test_editblock.py +++ b/tests/basic/test_editblock.py @@ -18,7 +18,7 @@ def setUp(self): 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 @@ def test_find_filename(self): 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):