python-rope / ropevim

vim mode that uses rope library to provide features like python refactorings and code-assists
GNU General Public License v2.0
249 stars 34 forks source link

Autocompletion - AttributeError: 'str' object has no attribute 'is_folder' #5

Closed mcepl closed 10 years ago

mcepl commented 11 years ago

Rope: 0.9.2. Ropevim & Ropemode - taken from http://rope.sourceforge.net/ropevim.html snapshot

In vim, when I activate autocompletion (M-/) with cursor positioned like this (X is cursor)

    grid = CompanyDataGrid()
    grid.X

following stacktrace will occur:

Error detected while processing function RopeCodeAssist:
line    1:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/ivan/.local/lib/python2.6/site-packages/ropemode/decorators.py", line 53, in newfunc
    return func(*args, **kwds)
  File "/home/ivan/.local/lib/python2.6/site-packages/ropemode/interface.py", line 226, in code_assist
    _CodeAssist(self, self.env).code_assist(prefix)
  File "/home/ivan/.local/lib/python2.6/site-packages/ropemode/interface.py", line 510, in code_assist
    proposals = self._calculate_proposals()
  File "/home/ivan/.local/lib/python2.6/site-packages/ropemode/interface.py", line 574, in _calculate_proposals
    resource, maxfixes=maxfixes)
  File "/usr/lib/python2.6/site-packages/rope/contrib/codeassist.py", line 33, in code_assist
    return assist()
  File "/usr/lib/python2.6/site-packages/rope/contrib/codeassist.py", line 245, in __call__
    completions = list(self._code_completions().values())
  File "/usr/lib/python2.6/site-packages/rope/contrib/codeassist.py", line 339, in _code_completions
    result.update(self._dotted_completions(module_scope, inner_scope))
  File "/usr/lib/python2.6/site-packages/rope/contrib/codeassist.py", line 255, in _dotted_completions
    element = found_pyname.get_object()
  File "/usr/lib/python2.6/site-packages/rope/base/pynamesdef.py", line 22, in get_object
    return self.pyobject.get()
  File "/usr/lib/python2.6/site-packages/rope/base/utils.py", line 25, in newfunc
    return func(self, *args, **kwds)
  File "/usr/lib/python2.6/site-packages/rope/base/pynames.py", line 186, in get
    self.set(self.get_inferred(*args, **kwds))
  File "/usr/lib/python2.6/site-packages/rope/base/utils.py", line 25, in newfunc
    return func(self, *args, **kwds)
  File "/usr/lib/python2.6/site-packages/rope/base/pynamesdef.py", line 19, in _get_inferred
    return rope.base.oi.soi.infer_assigned_object(self)
  File "/usr/lib/python2.6/site-packages/rope/base/utils.py", line 37, in newfunc
    return func(*args, **kwds)
  File "/usr/lib/python2.6/site-packages/rope/base/oi/soi.py", line 61, in infer_assigned_object
    result = _infer_assignment(assignment, pyname.module)
  File "/usr/lib/python2.6/site-packages/rope/base/utils.py", line 37, in newfunc
    return func(*args, **kwds)
  File "/usr/lib/python2.6/site-packages/rope/base/oi/soi.py", line 110, in _infer_assignment
    result = _follow_pyname(assignment, pymodule)
  File "/usr/lib/python2.6/site-packages/rope/base/utils.py", line 37, in newfunc
    return func(*args, **kwds)
  File "/usr/lib/python2.6/site-packages/rope/base/oi/soi.py", line 141, in _follow_pyname
    pyname = evaluate.eval_node(holding_scope, assign_node)
  File "/usr/lib/python2.6/site-packages/rope/base/evaluate.py", line 25, in eval_node
    return eval_node2(scope, node)[1]
  File "/usr/lib/python2.6/site-packages/rope/base/evaluate.py", line 30, in eval_node2
    ast.walk(node, evaluator)
  File "/usr/lib/python2.6/site-packages/rope/base/ast.py", line 30, in walk
    return method(node)
  File "/usr/lib/python2.6/site-packages/rope/base/evaluate.py", line 157, in _Call
    primary, pyobject = self._get_primary_and_object_for_node(node.func)
  File "/usr/lib/python2.6/site-packages/rope/base/evaluate.py", line 278, in _get_primary_and_object_for_node
    pyobject = pyname.get_object()
  File "/usr/lib/python2.6/site-packages/rope/base/utils.py", line 25, in newfunc
    return func(self, *args, **kwds)
  File "/usr/lib/python2.6/site-packages/rope/base/pynames.py", line 158, in get_object
    return self._get_imported_pyname().get_object()
  File "/usr/lib/python2.6/site-packages/rope/base/pynames.py", line 149, in _get_imported_pyname
    result = self.imported_module.get_object()[self.imported_name]
  File "/usr/lib/python2.6/site-packages/rope/base/pynames.py", line 130, in get_object
    if self._get_pymodule() is None:
  File "/usr/lib/python2.6/site-packages/rope/base/pynames.py", line 120, in _get_pymodule
    self._current_folder())
  File "/usr/lib/python2.6/site-packages/rope/base/pycore.py", line 77, in get_module
    module = self.find_module(name, folder)
  File "/usr/lib/python2.6/site-packages/rope/base/pycore.py", line 153, in find_module
    return self._find_module(modname, folder)
  File "/usr/lib/python2.6/site-packages/rope/base/pycore.py", line 166, in _find_module
    module = self._find_module_in_folder(src, modname)
  File "/usr/lib/python2.6/site-packages/rope/base/pycore.py", line 125, in _find_module_in_folder
    if  module.is_folder() and module.has_child(pkg):
AttributeError: 'str' object has no attribute 'is_folder'

This happens for custom classes (from my project), but not for buildin types (like dict) - eg. this works:

    d = {}
    d.X
mcepl commented 11 years ago

Does this happen for the repository version of rope?

mcepl commented 10 years ago

I have no clue what to do with this bug, because I cannot reproduce it at all. Please, reopen, if you have something to add.