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

Fix error "'_ExpressionVisitor' object has no attribute 'defineds'" #423

Merged
merged 2 commits into from Sep 29, 2021

Conversation

lieryan
Copy link
Member

@lieryan lieryan commented Sep 29, 2021

Description

In rope master, code that uses inline assignment (:= operator), doing a AutoImport.generate_cache() produces an error:

Traceback (most recent call last):
  File "ref.py", line 8, in <module>
    importer.generate_cache()
  File "/home/user/rope/rope/contrib/autoimport.py", line 107, in generate_cache
    self.update_resource(file, underlined)
  File "/home/user/rope/rope/contrib/autoimport.py", line 160, in update_resource
    self._add_names(pymodule, modname, underlined)
  File "/home/user/rope/rope/contrib/autoimport.py", line 183, in _add_names
    attributes = pymodule._get_structural_attributes()
  File "/home/user/rope/rope/base/utils/__init__.py", line 32, in newfunc
    return func(self, *args, **kwds)
  File "/home/user/rope/rope/base/pyobjects.py", line 179, in _get_structural_attributes
    self.structural_attributes = self._create_structural_attributes()
  File "/home/user/rope/rope/base/pyobjects.py", line 232, in _create_structural_attributes
    ast.walk(child, new_visitor)
  File "/home/user/rope/rope/base/ast.py", line 40, in walk
    return method(node)
  File "/home/user/rope/rope/base/pyobjectsdef.py", line 460, in _Assign
    ast.walk(node, _AssignVisitor(self))
  File "/home/user/rope/rope/base/ast.py", line 40, in walk
    return method(node)
  File "/home/user/rope/rope/base/pyobjectsdef.py", line 380, in _Assign
    ast.walk(node.value, _ExpressionVisitor(self.scope_visitor))
  File "/home/user/rope/rope/base/ast.py", line 42, in walk
    walk(child, walker)
  File "/home/user/rope/rope/base/ast.py", line 40, in walk
    return method(node)
  File "/home/user/rope/rope/base/pyobjectsdef.py", line 367, in _NamedExpr
    ast.walk(node.target, _AssignVisitor(self))
  File "/home/user/rope/rope/base/ast.py", line 40, in walk
    return method(node)
  File "/home/user/rope/rope/base/pyobjectsdef.py", line 392, in _Name
    self._assigned(node.id, assignment)
  File "/home/user/rope/rope/base/pyobjectsdef.py", line 383, in _assigned
    print(self.scope_visitor, self.scope_visitor.defineds)
AttributeError: '_ExpressionVisitor' object has no attribute 'defineds'

Checklist (delete if not relevant):

  • I have added tests that prove my fix is effective or that my feature works

@lieryan lieryan merged commit b83af9c into master Sep 29, 2021
@lieryan lieryan deleted the lieryan-fix-inline-assignment-scope branch September 29, 2021 01:21
@lieryan lieryan added this to the 0.21.x milestone Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant