From d8f3d155e6ebd26779561acf732aab5547ee8754 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sat, 18 May 2024 19:36:23 -0700 Subject: [PATCH] aider: Refactored the code to turn the matches into a list of `(filename, linenum)` pairs. # Aider chat conversation: USER: turn the matches into a list of (filename, linenum) where linenum is int ASSISTANT: Here is the *SEARCH/REPLACE* block to turn the matches into a list of `(filename, linenum)` where `linenum` is an integer: aider/linter.py ```python <<<<<<< SEARCH return matches ======= result = [] for match in matches: fname, linenum = match.rsplit(':', 1) result.append((fname, int(linenum))) return result >>>>>>> REPLACE ``` --- aider/linter.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/aider/linter.py b/aider/linter.py index 385d87a03..20304a508 100644 --- a/aider/linter.py +++ b/aider/linter.py @@ -171,7 +171,11 @@ def find_filenames_and_linenums(text, fnames): """ pattern = re.compile(r'(\b(?:' + '|'.join(re.escape(fname) for fname in fnames) + r'):\d+\b)') matches = pattern.findall(text) - return matches + result = [] + for match in matches: + fname, linenum = match.rsplit(':', 1) + result.append((fname, int(linenum))) + return result def main(): """