mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 14:25:00 +00:00
style: Format code and fix whitespace issues
This commit is contained in:
parent
5c9746e209
commit
b5d17b99df
2 changed files with 15 additions and 18 deletions
|
@ -128,7 +128,7 @@ class FileWatcher:
|
||||||
"""Process the detected changes and update state"""
|
"""Process the detected changes and update state"""
|
||||||
if not changes:
|
if not changes:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
changed_files = {str(Path(change[1])) for change in changes}
|
changed_files = {str(Path(change[1])) for change in changes}
|
||||||
self.changed_files.update(changed_files)
|
self.changed_files.update(changed_files)
|
||||||
self.io.interrupt_input()
|
self.io.interrupt_input()
|
||||||
|
@ -138,15 +138,13 @@ class FileWatcher:
|
||||||
"""Watch for file changes and process them"""
|
"""Watch for file changes and process them"""
|
||||||
try:
|
try:
|
||||||
roots_to_watch = self.get_roots_to_watch()
|
roots_to_watch = self.get_roots_to_watch()
|
||||||
|
|
||||||
for changes in watch(
|
for changes in watch(
|
||||||
*roots_to_watch,
|
*roots_to_watch, watch_filter=self.filter_func, stop_event=self.stop_event
|
||||||
watch_filter=self.filter_func,
|
|
||||||
stop_event=self.stop_event
|
|
||||||
):
|
):
|
||||||
if self.handle_changes(changes):
|
if self.handle_changes(changes):
|
||||||
return
|
return
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
dump(f"File watcher error: {e}")
|
dump(f"File watcher error: {e}")
|
||||||
|
@ -156,11 +154,8 @@ class FileWatcher:
|
||||||
"""Start watching for file changes"""
|
"""Start watching for file changes"""
|
||||||
self.stop_event = threading.Event()
|
self.stop_event = threading.Event()
|
||||||
self.changed_files = set()
|
self.changed_files = set()
|
||||||
|
|
||||||
self.watcher_thread = threading.Thread(
|
self.watcher_thread = threading.Thread(target=self.watch_files, daemon=True)
|
||||||
target=self.watch_files,
|
|
||||||
daemon=True
|
|
||||||
)
|
|
||||||
self.watcher_thread.start()
|
self.watcher_thread.start()
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
|
|
|
@ -65,16 +65,16 @@ def test_get_roots_to_watch(tmp_path):
|
||||||
# Create a test directory structure
|
# Create a test directory structure
|
||||||
(tmp_path / "included").mkdir()
|
(tmp_path / "included").mkdir()
|
||||||
(tmp_path / "excluded").mkdir()
|
(tmp_path / "excluded").mkdir()
|
||||||
|
|
||||||
io = InputOutput(pretty=False, fancy_input=False, yes=False)
|
io = InputOutput(pretty=False, fancy_input=False, yes=False)
|
||||||
coder = MinimalCoder(io)
|
coder = MinimalCoder(io)
|
||||||
|
|
||||||
# Test with no gitignore
|
# Test with no gitignore
|
||||||
watcher = FileWatcher(coder, root=tmp_path)
|
watcher = FileWatcher(coder, root=tmp_path)
|
||||||
roots = watcher.get_roots_to_watch()
|
roots = watcher.get_roots_to_watch()
|
||||||
assert len(roots) == 1
|
assert len(roots) == 1
|
||||||
assert roots[0] == str(tmp_path)
|
assert roots[0] == str(tmp_path)
|
||||||
|
|
||||||
# Test with gitignore
|
# Test with gitignore
|
||||||
gitignore = tmp_path / ".gitignore"
|
gitignore = tmp_path / ".gitignore"
|
||||||
gitignore.write_text("excluded/")
|
gitignore.write_text("excluded/")
|
||||||
|
@ -83,20 +83,22 @@ def test_get_roots_to_watch(tmp_path):
|
||||||
assert len(roots) == 1
|
assert len(roots) == 1
|
||||||
assert Path(roots[0]).name == "included"
|
assert Path(roots[0]).name == "included"
|
||||||
|
|
||||||
|
|
||||||
def test_handle_changes():
|
def test_handle_changes():
|
||||||
io = InputOutput(pretty=False, fancy_input=False, yes=False)
|
io = InputOutput(pretty=False, fancy_input=False, yes=False)
|
||||||
coder = MinimalCoder(io)
|
coder = MinimalCoder(io)
|
||||||
watcher = FileWatcher(coder)
|
watcher = FileWatcher(coder)
|
||||||
|
|
||||||
# Test no changes
|
# Test no changes
|
||||||
assert not watcher.handle_changes([])
|
assert not watcher.handle_changes([])
|
||||||
assert len(watcher.changed_files) == 0
|
assert len(watcher.changed_files) == 0
|
||||||
|
|
||||||
# Test with changes
|
# Test with changes
|
||||||
changes = [('modified', '/path/to/file.py')]
|
changes = [("modified", "/path/to/file.py")]
|
||||||
assert watcher.handle_changes(changes)
|
assert watcher.handle_changes(changes)
|
||||||
assert len(watcher.changed_files) == 1
|
assert len(watcher.changed_files) == 1
|
||||||
assert str(Path('/path/to/file.py')) in watcher.changed_files
|
assert str(Path("/path/to/file.py")) in watcher.changed_files
|
||||||
|
|
||||||
|
|
||||||
def test_ai_comment_pattern():
|
def test_ai_comment_pattern():
|
||||||
# Create minimal IO and Coder instances for testing
|
# Create minimal IO and Coder instances for testing
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue