diff --git a/jedi/evaluate/compiled/__init__.py b/jedi/evaluate/compiled/__init__.py index 4b9c158a..f051583f 100644 --- a/jedi/evaluate/compiled/__init__.py +++ b/jedi/evaluate/compiled/__init__.py @@ -169,6 +169,9 @@ class CompiledObject(Base): faked_subscopes.append(f) return faked_subscopes + def is_scope(self): + return True + def get_self_attributes(self): return [] # Instance compatibility diff --git a/jedi/evaluate/finder.py b/jedi/evaluate/finder.py index 26207f5c..a9c2ae0e 100644 --- a/jedi/evaluate/finder.py +++ b/jedi/evaluate/finder.py @@ -478,8 +478,7 @@ def get_names_of_scope(evaluator, scope, position=None, star_search=True, includ while scope: # We don't want submodules to report if we have modules. # As well as some non-scopes, which are parents of list comprehensions. - if isinstance(scope, pr.SubModule) and scope.parent \ - or not isinstance(scope, pr.IsScope): + if isinstance(scope, pr.SubModule) and scope.parent or not scope.is_scope(): scope = scope.parent continue # `pr.Class` is used, because the parent is never `Class`. diff --git a/jedi/parser/fast.py b/jedi/parser/fast.py index 93700532..4eff6958 100644 --- a/jedi/parser/fast.py +++ b/jedi/parser/fast.py @@ -16,7 +16,7 @@ from jedi.parser.tokenize import (source_tokens, Token, FLOWS, NEWLINE, COMMENT, ENDMARKER) -class Module(pr.Simple, pr.Module): +class Module(pr.Module, pr.Simple): def __init__(self, parsers): super(Module, self).__init__(self, (1, 0)) self.parsers = parsers diff --git a/jedi/parser/representation.py b/jedi/parser/representation.py index 37c60526..709e52b1 100644 --- a/jedi/parser/representation.py +++ b/jedi/parser/representation.py @@ -191,12 +191,18 @@ class Simple(Base): return "<%s: %s@%s,%s>" % \ (type(self).__name__, code, self.start_pos[0], self.start_pos[1]) + def is_scope(self): + return False + class IsScope(Base): __slots__ = () + def is_scope(self): + return True -class Scope(Simple, IsScope, DocstringMixin): + +class Scope(IsScope, Simple, DocstringMixin): """ Super class for the parser tree, which represents the state of a python text file.