mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 18:25:00 +00:00
aider: Accumulated a set of line numbers for each filename in the find_filenames_and_linenums
function.
# Aider chat conversation: USER: for each filename accumulate a set of the linenums it has ASSISTANT: To accumulate a set of line numbers for each filename, we need to modify the `find_filenames_and_linenums` function. Here is the *SEARCH/REPLACE* block: aider/linter.py ```python <<<<<<< SEARCH result = [] ======= result = {} >>>>>>> REPLACE ``` aider/linter.py ```python <<<<<<< SEARCH result.append((fname, int(linenum))) ======= if fname not in result: result[fname] = set() result[fname].add(int(linenum)) >>>>>>> REPLACE ```
This commit is contained in:
parent
d8f3d155e6
commit
2e72aabcf4
1 changed files with 4 additions and 2 deletions
|
@ -171,10 +171,12 @@ 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)
|
||||
result = []
|
||||
result = {}
|
||||
for match in matches:
|
||||
fname, linenum = match.rsplit(':', 1)
|
||||
result.append((fname, int(linenum)))
|
||||
if fname not in result:
|
||||
result[fname] = set()
|
||||
result[fname].add(int(linenum))
|
||||
return result
|
||||
|
||||
def main():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue