diff --git a/jedi/evaluate/helpers.py b/jedi/evaluate/helpers.py index 0389ac11..33c100c8 100644 --- a/jedi/evaluate/helpers.py +++ b/jedi/evaluate/helpers.py @@ -77,7 +77,7 @@ def deep_ast_copy(obj, new_elements_default=None, check_first=False): setattr(new_obj, key, d) elif isinstance(value, (list, tuple)): setattr(new_obj, key, sequence_recursion(value)) - elif isinstance(value, (pr.Simple, pr.Name)): + elif isinstance(value, (pr.BaseNode, pr.Name)): setattr(new_obj, key, recursion(value)) return new_obj diff --git a/jedi/evaluate/representation.py b/jedi/evaluate/representation.py index 94fa4c18..e1ed6d4a 100644 --- a/jedi/evaluate/representation.py +++ b/jedi/evaluate/representation.py @@ -311,7 +311,7 @@ class InstanceElement(use_metaclass(CachedMetaClass, pr.Base)): return par def get_parent_until(self, *args, **kwargs): - return pr.Simple.get_parent_until(self, *args, **kwargs) + return pr.BaseNode.get_parent_until(self, *args, **kwargs) def get_definition(self): return self.get_parent_until((pr.ExprStmt, pr.IsScope, pr.Import)) diff --git a/jedi/parser/tree.py b/jedi/parser/tree.py index 5f0578b4..52150efd 100644 --- a/jedi/parser/tree.py +++ b/jedi/parser/tree.py @@ -396,7 +396,7 @@ class Keyword(Leaf): return hash(self.value) -class Simple(Base): +class BaseNode(Base): """ The super class for Scope, Import, Name and Statement. Every object in the parser tree inherits from this class. @@ -405,7 +405,7 @@ class Simple(Base): def __init__(self, children): """ - Initialize :class:`Simple`. + Initialize :class:`BaseNode`. :param children: The module in which this Python object locates. """ @@ -475,7 +475,7 @@ class Simple(Base): (type(self).__name__, code, self.start_pos[0], self.start_pos[1]) -class Node(Simple): +class Node(BaseNode): """Concrete implementation for interior nodes.""" __slots__ = ('type',) @@ -504,7 +504,7 @@ class IsScope(use_metaclass(IsScopeMeta)): pass -class Scope(Simple, DocstringMixin): +class Scope(BaseNode, DocstringMixin): """ Super class for the parser tree, which represents the state of a python text file. @@ -646,7 +646,7 @@ class Module(Scope): return False -class Decorator(Simple): +class Decorator(BaseNode): type = 'decorator' __slots__ = () @@ -815,7 +815,7 @@ class Lambda(Function): return "<%s@%s>" % (self.__class__.__name__, self.start_pos) -class Flow(Simple): +class Flow(BaseNode): __slots__ = () @@ -899,7 +899,7 @@ class WithStmt(Flow): return node.children[0] -class Import(Simple): +class Import(BaseNode): __slots__ = () def path_for_name(self, name): @@ -1038,7 +1038,7 @@ class ImportName(Import): if alias is not None) -class KeywordStatement(Simple): +class KeywordStatement(BaseNode): """ For the following statements: `assert`, `del`, `global`, `nonlocal`, `raise`, `return`, `yield`, `pass`, `continue`, `break`, `return`, `yield`. @@ -1074,7 +1074,7 @@ class ReturnStmt(KeywordStatement): __slots__ = () -class YieldExpr(Simple): +class YieldExpr(BaseNode): type = 'yield_expr' __slots__ = () @@ -1100,7 +1100,7 @@ def _defined_names(current): return names -class ExprStmt(Simple, DocstringMixin): +class ExprStmt(BaseNode, DocstringMixin): type = 'expr_stmt' __slots__ = () @@ -1183,7 +1183,7 @@ class Param(Base): return '<%s: %s>' % (type(self).__name__, str(self.tfpdef) + default) -class CompFor(Simple): +class CompFor(BaseNode): type = 'comp_for' __slots__ = ()