diff --git a/jedi/evaluate/helpers.py b/jedi/evaluate/helpers.py index ca94016d..0389ac11 100644 --- a/jedi/evaluate/helpers.py +++ b/jedi/evaluate/helpers.py @@ -156,10 +156,6 @@ def get_module_names(module, all_scopes): return chain.from_iterable(dct.values()) -class FakeSubModule(): - line_offset = 0 - - class FakeImport(pr.Import): def __init__(self, name, parent, level=0): super(FakeImport, self).__init__([]) diff --git a/jedi/parser/__init__.py b/jedi/parser/__init__.py index ed8e0b9d..ea99e550 100644 --- a/jedi/parser/__init__.py +++ b/jedi/parser/__init__.py @@ -90,7 +90,7 @@ class Parser(object): 'expr_stmt': pt.ExprStmt, 'classdef': pt.Class, 'funcdef': pt.Function, - 'file_input': pt.SubModule, + 'file_input': pt.Module, 'import_name': pt.ImportName, 'import_from': pt.ImportFrom, 'break_stmt': pt.KeywordStatement, diff --git a/jedi/parser/fast.py b/jedi/parser/fast.py index 582f19ce..b5e36926 100644 --- a/jedi/parser/fast.py +++ b/jedi/parser/fast.py @@ -10,7 +10,6 @@ from jedi._compatibility import use_metaclass, unicode from jedi import settings from jedi.parser import Parser from jedi.parser import tree as pr -from jedi.parser import tokenize from jedi import cache from jedi import debug from jedi.parser.tokenize import (source_tokens, NEWLINE, @@ -19,7 +18,7 @@ from jedi.parser.tokenize import (source_tokens, NEWLINE, FLOWS = ['if', 'else', 'elif', 'while', 'with', 'try', 'except', 'finally', 'for'] -class FastModule(pr.SubModule): +class FastModule(pr.Module): type = 'file_input' def __init__(self, module_path): diff --git a/jedi/parser/tree.py b/jedi/parser/tree.py index 9749c699..5f0578b4 100644 --- a/jedi/parser/tree.py +++ b/jedi/parser/tree.py @@ -11,16 +11,16 @@ By using `get_code` on a module, you can get back the 1-to-1 representation of the input given to the parser. This is important if you are using refactoring. The easiest way to play with this module is to use :class:`parsing.Parser`. -:attr:`parsing.Parser.module` holds an instance of :class:`SubModule`: +:attr:`parsing.Parser.module` holds an instance of :class:`Module`: >>> from jedi._compatibility import u >>> from jedi.parser import Parser, load_grammar >>> parser = Parser(load_grammar(), u('import os'), 'example.py') >>> submodule = parser.module >>> submodule - + -Any subclasses of :class:`Scope`, including :class:`SubModule` has an attribute +Any subclasses of :class:`Scope`, including :class:`Module` has an attribute :attr:`imports `: >>> submodule.imports @@ -63,7 +63,7 @@ class DocstringMixin(object): @property def raw_doc(self): """ Returns a cleaned version of the docstring token. """ - if isinstance(self, SubModule): + if isinstance(self, Module): stmt = self.children[0] else: stmt = self.children[self.children.index(':') + 1] @@ -589,17 +589,7 @@ class Scope(Simple, DocstringMixin): r = r.next -class Module(Base): - """ - For isinstance checks. fast_parser.Module also inherits from this. - """ - __slots__ = () - - def is_scope(self): - return True - - -class SubModule(Scope, Module): +class Module(Scope): """ The top scope, which is always a module. Depending on the underlying parser this may be a full module or just a part @@ -611,14 +601,14 @@ class SubModule(Scope, Module): def __init__(self, children): """ - Initialize :class:`SubModule`. + Initialize :class:`Module`. :type path: str :arg path: File path to this module. .. todo:: Document `top_module`. """ - super(SubModule, self).__init__(children) + super(Module, self).__init__(children) self.path = None # Set later. @property