mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 02:05:00 +00:00
aider: Fix 'dict_items' object has no attribute 'next' error by using 'next(iter(...))' to iterate over dictionary items in Python 3.
# Aider chat conversation: USER: Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/Users/gauthier/Projects/aider/aider/linter.py", line 203, in <module> main() File "/Users/gauthier/Projects/aider/aider/linter.py", line 197, in main errors = linter.lint(file_path) ^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gauthier/Projects/aider/aider/linter.py", line 76, in lint return self.run_cmd(cmd, rel_fname, code) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gauthier/Projects/aider/aider/linter.py", line 57, in run_cmd filename, linenums = filenames_linenums.items().next() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'dict_items' object has no attribute 'next' ASSISTANT: To fix the `AttributeError: 'dict_items' object has no attribute 'next'`, we need to update the code to use the correct method for iterating over dictionary items in Python 3. The `next()` method should be replaced with `next(iter(...))`. Here is the *SEARCH/REPLACE* block: aider/linter.py ```python <<<<<<< SEARCH if filenames_linenums: filename, linenums = filenames_linenums.items().next() res += tree_context(rel_fname, code, linenums) ======= if filenames_linenums: filename, linenums = next(iter(filenames_linenums.items())) res += tree_context(rel_fname, code, linenums) >>>>>>> REPLACE ```
This commit is contained in:
parent
d8a5108f9e
commit
f69da2cd86
1 changed files with 1 additions and 1 deletions
|
@ -54,7 +54,7 @@ class Linter:
|
|||
|
||||
filenames_linenums = find_filenames_and_linenums(errors, [rel_fname])
|
||||
if filenames_linenums:
|
||||
filename, linenums = filenames_linenums.items().next()
|
||||
filename, linenums = next(iter(filenames_linenums.items()))
|
||||
res += tree_context(rel_fname, code, linenums)
|
||||
|
||||
return res
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue