Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename fails with missing KeyError: MatMul in patchedast #496

Closed
lieryan opened this issue Jul 14, 2022 · 0 comments · Fixed by #497
Closed

Rename fails with missing KeyError: MatMul in patchedast #496

lieryan opened this issue Jul 14, 2022 · 0 comments · Fixed by #497
Labels
bug Unexpected or incorrect user-visible behavior
Milestone

Comments

@lieryan
Copy link
Member

lieryan commented Jul 14, 2022

Ticket originally reported by @eivindjahren in ropevim (python-rope/ropevim#91).

running RopeRenameCurrentModule on ubuntu 22.04, neovim 0.7.2, python 3.10, rope 1.2.0, results in the following error:

Error detected while processing function RopeRenameCurrentModule[1]..provider#python3#Call:
line   18:
Error invoking 'python_execute' on channel 3 (python3-script-host):
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "~/.local/lib/python3.10/site-packages/ropemode/decorators.py", line 54, in newfunc
    return func(*args, **kwds)
  File "~/.local/lib/python3.10/site-packages/ropemode/interface.py", line 52, in do_refactor
    refactoring(self, self.env).show(initial_asking=initial_asking)
  File "~/.local/lib/python3.10/site-packages/ropemode/refactor.py", line 43, in show
    changes = runtask(self.env, calculate, name=name)
  File "~/.local/lib/python3.10/site-packages/ropemode/refactor.py", line 469, in runtask
    return RunTask(env, command, name, interrupts)()
  File "~/.local/lib/python3.10/site-packages/ropemode/refactor.py", line 489, in __call__
    result = self.task(handle)
  File "~/.local/lib/python3.10/site-packages/ropemode/refactor.py", line 41, in calculate
    return self._calculate_changes(result, handle)
  File "~/.local/lib/python3.10/site-packages/ropemode/refactor.py", line 122, in _calculate_changes
    return self.renamer.get_changes(task_handle=task_handle, **values)
  File "~/.local/lib/python3.10/site-packages/rope/refactor/rename.py", line 121, in get_changes
    new_content = rename_in_module(finder, new_name, resource=file_)
  File "~/.local/lib/python3.10/site-packages/rope/refactor/rename.py", line 235, in rename_in_module
    for occurrence in occurrences_finder.find_occurrences(resource, pymodule):
  File "~/.local/lib/python3.10/site-packages/rope/refactor/occurrences.py", line 80, in find_occurrences
    result = filter(occurrence)
  File "~/.local/lib/python3.10/site-packages/rope/refactor/occurrences.py", line 224, in __call__
    if same_pyname(self.pyname, occurrence.get_pyname()):
  File "~/.local/lib/python3.10/site-packages/rope/base/utils/__init__.py", line 12, in _wrapper
    setattr(self, name, func(self, *args, **kwds))
  File "~/.local/lib/python3.10/site-packages/rope/refactor/occurrences.py", line 147, in get_pyname
    return self.tools.name_finder.get_pyname_at(self.offset)
  File "~/.local/lib/python3.10/site-packages/rope/base/evaluate.py", line 83, in get_pyname_at
    return self.get_primary_and_pyname_at(offset)[1]
  File "~/.local/lib/python3.10/site-packages/rope/base/evaluate.py", line 87, in get_primary_and_pyname_at
    holding_scope = self.module_scope.get_inner_scope_for_offset(offset)
  File "~/.local/lib/python3.10/site-packages/rope/base/pyscopes.py", line 158, in get_inner_scope_for_offset
    return self._scope_finder.get_holding_scope_for_offset(self, offset)
  File "~/.local/lib/python3.10/site-packages/rope/base/pyscopes.py", line 315, in get_holding_scope_for_offset
    if inner_scope.in_region(offset):
  File "~/.local/lib/python3.10/site-packages/rope/base/pyscopes.py", line 116, in in_region
    region = self.get_region()
  File "~/.local/lib/python3.10/site-packages/rope/base/pyscopes.py", line 105, in get_region
    self._calculate_scope_regions_for_module()
  File "~/.local/lib/python3.10/site-packages/rope/base/pyscopes.py", line 111, in _calculate_scope_regions_for_module
    self._get_global_scope()._calculate_scope_regions()
  File "~/.local/lib/python3.10/site-packages/rope/base/utils/__init__.py", line 12, in _wrapper
    setattr(self, name, func(self, *args, **kwds))
  File "~/.local/lib/python3.10/site-packages/rope/base/pyscopes.py", line 142, in _calculate_scope_regions
    patchedast.patch_ast(self.pyobject.get_ast(), source)
  File "~/.local/lib/python3.10/site-packages/rope/refactor/patchedast.py", line 44, in patch_ast
    ast.call_for_nodes(node, walker)
  File "~/.local/lib/python3.10/site-packages/rope/base/ast.py", line 62, in call_for_nodes
    result = callback(node)
  File "~/.local/lib/python3.10/site-packages/rope/refactor/patchedast.py", line 91, in __call__
    return method(node)
  File "~/.local/lib/python3.10/site-packages/rope/refactor/patchedast.py", line 723, in _Module
    self._handle(node, list(node.body), eat_spaces=True)
  File "~/.local/lib/python3.10/site-packages/rope/refactor/patchedast.py", line 124, in _handle
    ast.call_for_nodes(child, self)
  File "~/.local/lib/python3.10/site-packages/rope/base/ast.py", line 62, in call_for_nodes
    result = callback(node)
  File "~/.local/lib/python3.10/site-packages/rope/refactor/patchedast.py", line 91, in __call__
    return method(node)
  File "~/.local/lib/python3.10/site-packages/rope/refactor/patchedast.py", line 586, in _FunctionDef
    self._handle_function_def_node(node, is_async=False)
  File "~/.local/lib/python3.10/site-packages/rope/refactor/patchedast.py", line 583, in _handle_function_def_node
    self._handle(node, children)
  File "~/.local/lib/python3.10/site-packages/rope/refactor/patchedast.py", line 124, in _handle
    ast.call_for_nodes(child, self)
  File "~/.local/lib/python3.10/site-packages/rope/base/ast.py", line 62, in call_for_nodes
    result = callback(node)
  File "~/.local/lib/python3.10/site-packages/rope/refactor/patchedast.py", line 91, in __call__
    return method(node)
  File "~/.local/lib/python3.10/site-packages/rope/refactor/patchedast.py", line 546, in _For
    self._handle_for_loop_node(node, is_async=False)
  File "~/.local/lib/python3.10/site-packages/rope/refactor/patchedast.py", line 543, in _handle_for_loop_node
    self._handle(node, children)
  File "~/.local/lib/python3.10/site-packages/rope/refactor/patchedast.py", line 124, in _handle
    ast.call_for_nodes(child, self)
  File "~/.local/lib/python3.10/site-packages/rope/base/ast.py", line 62, in call_for_nodes
    result = callback(node)
  File "~/.local/lib/python3.10/site-packages/rope/refactor/patchedast.py", line 91, in __call__
    return method(node)
  File "~/.local/lib/python3.10/site-packages/rope/refactor/patchedast.py", line 319, in _Assign
    self._handle(node, children)
  File "~/.local/lib/python3.10/site-packages/rope/refactor/patchedast.py", line 124, in _handle
    ast.call_for_nodes(child, self)
  File "~/.local/lib/python3.10/site-packages/rope/base/ast.py", line 62, in call_for_nodes
    result = callback(node)
  File "~/.local/lib/python3.10/site-packages/rope/refactor/patchedast.py", line 91, in __call__
    return method(node)
  File "~/.local/lib/python3.10/site-packages/rope/refactor/patchedast.py", line 338, in _BinOp
    children = [node.left] + self._get_op(node.op) + [node.right]
  File "~/.local/lib/python3.10/site-packages/rope/refactor/patchedast.py", line 303, in _get_op
    return self._operators[node.__class__.__name__].split(" ")
KeyError: 'MatMult'
@lieryan lieryan added the bug Unexpected or incorrect user-visible behavior label Jul 14, 2022
@lieryan lieryan modified the milestones: 1.3.0, 1.4.0 Jul 14, 2022
@lieryan lieryan modified the milestones: 1.4.0, 1.3.0 Jul 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected or incorrect user-visible behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant