Commits

Anonymous committed fe0a91f

using name in pyscope instead of name in pyscope.get_names()

  • Participants
  • Parent commits 2aa7f06

Comments (0)

Files changed (3)

rope/contrib/generate.py

     def element_already_exists(self):
         if self.pyname is None or isinstance(self.pyname, pynames.UnboundName):
             return False
-        if self.get_name() not in self.goal_scope.get_names():
+        if self.get_name() not in self.goal_scope:
             return False
         return True
 

rope/refactor/wildcards.py

             class _BuiltinsStub(object):
                 def get_attribute(self, name):
                     return builtins.builtins[name]
+                def __getitem__(self, name):
+                    return builtins.builtins[name]
+                def __contains__(self, name):
+                    return name in builtins.builtins
             pyobject = _BuiltinsStub()
         else:
             pyobject = self.project.pycore.get_module(attributes[0])

ropetest/pyscopestest.py

         self.assertEquals(1, len(sample_class_scope.get_names()))
         self.assertEquals(1, len(sample_class_scope.get_scopes()))
         f_in_class = sample_class_scope.get_scopes()[0]
-        self.assertTrue('var' in f_in_class.get_names())
+        self.assertTrue('var' in f_in_class)
 
     def test_get_lineno(self):
         scope = self.pycore.get_string_scope(
         scope = self.pycore.get_string_scope(
             'def sample_func(param):\n    a = 10\n')
         sample_func_scope = scope.get_scopes()[0]
-        self.assertTrue('param' in sample_func_scope.get_names())
+        self.assertTrue('param' in sample_func_scope)
 
     def test_get_names_contains_only_names_defined_in_a_scope(self):
         scope = self.pycore.get_string_scope(
             'var1 = 10\ndef sample_func(param):\n    var2 = 20\n')
         sample_func_scope = scope.get_scopes()[0]
-        self.assertTrue('var1' not in sample_func_scope.get_names())
+        self.assertTrue('var1' not in sample_func_scope)
 
     def test_scope_lookup(self):
         scope = self.pycore.get_string_scope(
     def test_function_scopes(self):
         scope = self.pycore.get_string_scope('def func():\n    var = 10\n')
         func_scope = scope.get_scopes()[0]
-        self.assertTrue('var' in func_scope.get_names())
+        self.assertTrue('var' in func_scope)
 
     def test_function_scopes_classes(self):
         scope = self.pycore.get_string_scope(
             'def func():\n    class Sample(object):\n        pass\n')
         func_scope = scope.get_scopes()[0]
-        self.assertTrue('Sample' in func_scope.get_names())
+        self.assertTrue('Sample' in func_scope)
 
     def test_function_getting_scope(self):
         mod = self.pycore.get_string_module('def func():    var = 10\n')
         func_scope = mod['func'].get_object().get_scope()
-        self.assertTrue('var' in func_scope.get_names())
+        self.assertTrue('var' in func_scope)
 
     def test_scopes_in_function_scopes(self):
         scope = self.pycore.get_string_scope(
             'def func():\n    def inner():\n        var = 10\n')
         func_scope = scope.get_scopes()[0]
         inner_scope = func_scope.get_scopes()[0]
-        self.assertTrue('var' in inner_scope.get_names())
+        self.assertTrue('var' in inner_scope)
 
     def test_for_variables_in_scopes(self):
         scope = self.pycore.get_string_scope(
             'for a_var in range(10):\n    pass\n')
-        self.assertTrue('a_var' in scope.get_names())
+        self.assertTrue('a_var' in scope)
 
     def test_assists_inside_fors(self):
         scope = self.pycore.get_string_scope(
             'for i in range(10):\n    a_var = i\n')
-        self.assertTrue('a_var' in scope.get_names())
+        self.assertTrue('a_var' in scope)
 
     def test_first_parameter_of_a_method(self):
         code = 'class AClass(object):\n' \