From 1c84fc97a126fa0a5a11df3368f02665def6fd4d Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Sun, 1 Dec 2024 07:52:47 -0800 Subject: [PATCH] refactor: remove try/except block and AI comment from watch.py --- aider/watch.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/aider/watch.py b/aider/watch.py index 0eefa7667..193ea41e7 100644 --- a/aider/watch.py +++ b/aider/watch.py @@ -200,18 +200,14 @@ class FileWatcher: """Extract AI comment line numbers and bang status from a file""" line_nums = [] has_bang = False - # remove try/except #ai! - try: - content = self.io.read_text(filepath) - for i, line in enumerate(content.splitlines(), 1): - if match := self.ai_comment_pattern.search(line): - comment = match.group(0).strip() - if comment: - line_nums.append(i) - if comment.strip().endswith("!"): - has_bang = True - except Exception: - return None, False + content = self.io.read_text(filepath) + for i, line in enumerate(content.splitlines(), 1): + if match := self.ai_comment_pattern.search(line): + comment = match.group(0).strip() + if comment: + line_nums.append(i) + if comment.strip().endswith("!"): + has_bang = True if not line_nums: return None, False return line_nums, has_bang