diff --git a/jedi/api.py b/jedi/api.py index 72c0376f..dc32752d 100644 --- a/jedi/api.py +++ b/jedi/api.py @@ -237,7 +237,8 @@ class Script(object): # add keywords scopes |= keywords.get_keywords(string=goto_path, pos=self.pos) - d = set([api_classes.Definition(s) for s in scopes]) + d = set([api_classes.Definition(s) for s in scopes + if not isinstance(s, imports.ImportPath._GlobalNamespace)]) return sorted(d, key=lambda x: (x.module_path, x.start_pos)) def goto(self): diff --git a/jedi/api_classes.py b/jedi/api_classes.py index 767235a8..80109ad8 100644 --- a/jedi/api_classes.py +++ b/jedi/api_classes.py @@ -34,10 +34,7 @@ class BaseDefinition(object): self.is_keyword = isinstance(definition, keywords.Keyword) # generate a path to the definition - try: - self.module_path = str(definition.get_parent_until().path) - except AttributeError: - self.module_path = None + self.module_path = str(definition.get_parent_until().path) @property def type(self): @@ -231,8 +228,6 @@ class Definition(BaseDefinition): d = 'module %s' % self.module_name elif self.is_keyword: d = 'keyword %s' % d.name - elif isinstance(d, type(imports.ImportPath.GlobalNamespace)): - d = 'Global Namespace' else: d = d.get_code().replace('\n', '') return d diff --git a/test/regression.py b/test/regression.py index 9474043f..fa62e169 100755 --- a/test/regression.py +++ b/test/regression.py @@ -262,7 +262,7 @@ class TestRegression(Base): assert [d.doc for d in defs] defs = self.get_def("import") - print [d.doc for d in defs] + assert len(defs) == 1 assert [d.doc for d in defs]