diff --git a/jedi/evaluate/imports.py b/jedi/evaluate/imports.py index 8660782b..9bd2d10b 100644 --- a/jedi/evaluate/imports.py +++ b/jedi/evaluate/imports.py @@ -230,7 +230,12 @@ class NestedImportModule(pr.Module): debug.dbg('Generated a nested import: %s', new) return helpers.FakeName(str(i.namespace.names[1]), new) - def get_defined_names(self): + def _get_defined_names(self): + """ + NesteImportModule don't seem to be actively used, right now. + However, they might in the future. If we do more sophisticated static + analysis checks. + """ nested = self._get_nested_import_name() return self._module.get_defined_names() + [nested] @@ -256,12 +261,6 @@ class StarImportModule(pr.Module): for s in self.star_import_modules: yield s, s.get_defined_names() - def get_defined_names(self): - result = self._module.get_defined_names() - for m in self.star_import_modules: - result += m.get_defined_names() - return result - def __getattr__(self, name): return getattr(self._module, name) diff --git a/jedi/evaluate/iterable.py b/jedi/evaluate/iterable.py index 36b432e1..b4d282dc 100644 --- a/jedi/evaluate/iterable.py +++ b/jedi/evaluate/iterable.py @@ -183,8 +183,8 @@ class Array(use_metaclass(CachedMetaClass, pr.Base)): # `array.type` is a string with the type, e.g. 'list'. scope = self._evaluator.find_types(compiled.builtin, self._array.type)[0] scope = self._evaluator.execute(scope)[0] # builtins only have one class - names = scope.get_defined_names() - yield self, [ArrayMethod(n) for n in names] + for _, names in scope.scope_names_generator(): + yield self, [ArrayMethod(n) for n in names] @common.safe_property def parent(self): diff --git a/jedi/evaluate/representation.py b/jedi/evaluate/representation.py index 709aa891..74ffcdad 100644 --- a/jedi/evaluate/representation.py +++ b/jedi/evaluate/representation.py @@ -139,18 +139,6 @@ class Instance(use_metaclass(CachedMetaClass, Executable)): args = [obj, obj.base] if isinstance(obj, Instance) else [None, obj] return self.execute_subscope_by_name('__get__', args) - @memoize_default([]) - def get_defined_names(self): - """ - Get the instance vars of a class. This includes the vars of all - classes - """ - names = self.get_self_attributes() - - for var in self.base.instance_names(): - names.append(InstanceElement(self._evaluator, self, var, True)) - return names - def scope_names_generator(self, position=None): """ An Instance has two scopes: The scope with self names and the class @@ -309,12 +297,6 @@ class Class(use_metaclass(CachedMetaClass, pr.IsScope)): result += super_result return result - @memoize_default(default=()) - def get_defined_names(self): - result = self.instance_names() - type_cls = self._evaluator.find_types(compiled.builtin, 'type')[0] - return result + list(type_cls.get_defined_names()) - def scope_names_generator(self, position=None): yield self, self.instance_names() yield self, compiled.type_names diff --git a/test/test_evaluate/test_compiled.py b/test/test_evaluate/test_compiled.py index 449dce3d..e238cd81 100644 --- a/test/test_evaluate/test_compiled.py +++ b/test/test_evaluate/test_compiled.py @@ -62,5 +62,5 @@ def test_string_literals(): assert typ('b""') == 'bytes' assert typ('u""') == 'str' else: - assert typ('b""') == 'string' + assert typ('b""') == 'str' assert typ('u""') == 'unicode'