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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions rope/base/pyobjectsdef.py
Expand Up @@ -342,6 +342,9 @@ class _ExpressionVisitor(object):
def __init__(self, scope_visitor):
self.scope_visitor = scope_visitor

def _assigned(self, name, assignment=None):
self.scope_visitor._assigned(name, assignment)

def _GeneratorExp(self, node):
list_comp = PyComprehension(
self.scope_visitor.pycore, node, self.scope_visitor.owner_object
Expand Down
11 changes: 11 additions & 0 deletions ropetest/pyscopestest.py
Expand Up @@ -95,6 +95,17 @@ def test_dict_comprehension_scope(self):
["b_var", "c_var"],
)

@testutils.only_for_versions_higher("3.8")
def test_inline_assignment(self):
scope = libutils.get_string_scope(
self.project,
"""values = (a_var := 2,)""",
)
self.assertEqual(
list(sorted(scope.get_defined_names())),
["a_var", "values"],
)

@testutils.only_for_versions_higher("3.8")
def test_inline_assignment_in_comprehensions(self):
scope = libutils.get_string_scope(
Expand Down