From 5d46f8e41354ea1db47a6bea4fc51a050c847a1d Mon Sep 17 00:00:00 2001 From: Lie Ryan Date: Wed, 29 Sep 2021 11:12:54 +1000 Subject: [PATCH 1/2] Fix error "'_ExpressionVisitor' object has no attribute 'defineds'" In code that has inline assignment (:= operator) --- rope/base/pyobjectsdef.py | 3 +++ ropetest/pyscopestest.py | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/rope/base/pyobjectsdef.py b/rope/base/pyobjectsdef.py index ec26d80a0..267e8acf5 100644 --- a/rope/base/pyobjectsdef.py +++ b/rope/base/pyobjectsdef.py @@ -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 diff --git a/ropetest/pyscopestest.py b/ropetest/pyscopestest.py index 75a309c4c..c2cd535ff 100644 --- a/ropetest/pyscopestest.py +++ b/ropetest/pyscopestest.py @@ -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( From f6eeda059b9b06a0251a64705501cb38d15d3848 Mon Sep 17 00:00:00 2001 From: Lie Ryan Date: Wed, 29 Sep 2021 11:19:56 +1000 Subject: [PATCH 2/2] Add test version specifier --- ropetest/pyscopestest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ropetest/pyscopestest.py b/ropetest/pyscopestest.py index c2cd535ff..2e76ad287 100644 --- a/ropetest/pyscopestest.py +++ b/ropetest/pyscopestest.py @@ -95,7 +95,7 @@ def test_dict_comprehension_scope(self): ["b_var", "c_var"], ) - # @testutils.only_for_versions_higher("3.8") + @testutils.only_for_versions_higher("3.8") def test_inline_assignment(self): scope = libutils.get_string_scope( self.project,