refactor: remove try/except block and AI comment from watch.py

This commit is contained in:
Paul Gauthier (aider) 2024-12-01 07:52:47 -08:00
parent 8b371ead92
commit 1c84fc97a1

View file

@ -200,18 +200,14 @@ class FileWatcher:
"""Extract AI comment line numbers and bang status from a file""" """Extract AI comment line numbers and bang status from a file"""
line_nums = [] line_nums = []
has_bang = False has_bang = False
# remove try/except #ai! content = self.io.read_text(filepath)
try: for i, line in enumerate(content.splitlines(), 1):
content = self.io.read_text(filepath) if match := self.ai_comment_pattern.search(line):
for i, line in enumerate(content.splitlines(), 1): comment = match.group(0).strip()
if match := self.ai_comment_pattern.search(line): if comment:
comment = match.group(0).strip() line_nums.append(i)
if comment: if comment.strip().endswith("!"):
line_nums.append(i) has_bang = True
if comment.strip().endswith("!"):
has_bang = True
except Exception:
return None, False
if not line_nums: if not line_nums:
return None, False return None, False
return line_nums, has_bang return line_nums, has_bang