| # Copyright (c) 2015-2016 Cara Vinson <ceridwenv@gmail.com> |
| # Copyright (c) 2015-2016 Claudiu Popa <pcmanticore@gmail.com> |
| |
| # Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html |
| # For details: https://github.com/PyCQA/astroid/blob/master/COPYING.LESSER |
| |
| |
| """Abstract classes for nodes and other runtime objects. |
| |
| The idea is that these objects are used for isinstance checks and |
| any other use cases where the need for a concrete type does not exist, |
| while other cases, such as instantiating a node, should use the concrete |
| types instead. |
| """ |
| |
| import abc |
| |
| import six |
| |
| |
| |
| @six.add_metaclass(abc.ABCMeta) |
| class NodeNG(object): |
| """Base Class for all Astroid node classes. |
| |
| It represents a node of the new abstract syntax tree. |
| """ |
| is_statement = False |
| |
| def __init__(self, lineno=None, col_offset=None, parent=None): |
| self.lineno = lineno |
| self.col_offset = col_offset |
| self.parent = parent |
| |
| @abc.abstractmethod |
| def infer(self, context=None, **kwargs): |
| """Main interface to the interface system, return a generator on inferred values.""" |
| |
| |
| # pylint: disable=abstract-method |
| |
| class Statement(NodeNG): |
| """Represents a Statement node.""" |
| is_statement = True |
| |
| |
| class AssignName(NodeNG): |
| """Class representing an AssignName node""" |
| |
| |
| class DelName(NodeNG): |
| """Class representing a DelName node""" |
| |
| |
| class Name(NodeNG): |
| """Class representing a Name node""" |
| |
| |
| class Parameter(NodeNG): |
| """Class representing a parameter node.""" |
| |
| |
| class Arguments(NodeNG): |
| """Class representing an Arguments node""" |
| |
| |
| class AssignAttr(NodeNG): |
| """Class representing an AssignAttr node""" |
| |
| |
| class Assert(Statement): |
| """Class representing an Assert node""" |
| |
| |
| class Assign(Statement): |
| """Class representing an Assign node""" |
| |
| |
| class AugAssign(Statement): |
| """Class representing an AugAssign node""" |
| |
| |
| class Repr(NodeNG): |
| """Class representing a Repr node""" |
| |
| |
| class BinOp(NodeNG): |
| """Class representing a BinOp node""" |
| |
| |
| class BoolOp(NodeNG): |
| """Class representing a BoolOp node""" |
| |
| |
| class Break(Statement): |
| """Class representing a Break node""" |
| |
| |
| class Call(NodeNG): |
| """Class representing a Call node""" |
| |
| |
| class Compare(NodeNG): |
| """Class representing a Compare node""" |
| |
| |
| class Comprehension(NodeNG): |
| """Class representing a Comprehension node""" |
| |
| |
| class Const(NodeNG): |
| """Represent a constant node like num, str, bool, None, bytes""" |
| |
| |
| class NameConstant(Const): |
| """Represents a builtin singleton, at the moment True, False, None, |
| and NotImplemented. |
| |
| """ |
| |
| class Continue(Statement): |
| """Class representing a Continue node""" |
| |
| |
| class Decorators(NodeNG): |
| """Class representing a Decorators node""" |
| |
| |
| class DelAttr(NodeNG): |
| """Class representing a DelAttr node""" |
| |
| |
| class Delete(Statement): |
| """Class representing a Delete node""" |
| |
| |
| class Dict(NodeNG): |
| """Class representing a Dict node""" |
| |
| |
| class Expr(Statement): |
| """Class representing a Expr node""" |
| |
| |
| class Ellipsis(NodeNG): # pylint: disable=redefined-builtin |
| """Class representing an Ellipsis node""" |
| |
| |
| class ExceptHandler(Statement): |
| """Class representing an ExceptHandler node""" |
| |
| |
| class Exec(Statement): |
| """Class representing an Exec node""" |
| |
| |
| class ExtSlice(NodeNG): |
| """Class representing an ExtSlice node""" |
| |
| |
| class For(Statement): |
| """Class representing a For node""" |
| |
| |
| class AsyncFor(For): |
| """Asynchronous For built with `async` keyword.""" |
| |
| |
| class Await(NodeNG): |
| """Await node for the `await` keyword.""" |
| |
| |
| class ImportFrom(Statement): |
| """Class representing a ImportFrom node""" |
| |
| |
| class Attribute(NodeNG): |
| """Class representing a Attribute node""" |
| |
| |
| class Global(Statement): |
| """Class representing a Global node""" |
| |
| |
| class If(Statement): |
| """Class representing an If node""" |
| |
| |
| class IfExp(NodeNG): |
| """Class representing an IfExp node""" |
| |
| |
| class Import(Statement): |
| """Class representing an Import node""" |
| |
| |
| class Index(NodeNG): |
| """Class representing an Index node""" |
| |
| |
| class Keyword(NodeNG): |
| """Class representing a Keyword node""" |
| |
| |
| class List(NodeNG): |
| """Class representing a List node""" |
| |
| |
| class Nonlocal(Statement): |
| """Class representing a Nonlocal node""" |
| |
| |
| class Pass(Statement): |
| """Class representing a Pass node""" |
| |
| |
| class Print(Statement): |
| """Class representing a Print node""" |
| |
| |
| class Raise(Statement): |
| """Class representing a Raise node""" |
| |
| |
| class Return(Statement): |
| """Class representing a Return node""" |
| |
| |
| class Set(NodeNG): |
| """Class representing a Set node""" |
| |
| |
| class Slice(NodeNG): |
| """Class representing a Slice node""" |
| |
| |
| class Starred(NodeNG): |
| """Class representing a Starred node""" |
| |
| |
| class Subscript(NodeNG): |
| """Class representing a Subscript node""" |
| |
| |
| class TryExcept(Statement): |
| """Class representing a TryExcept node""" |
| |
| |
| class TryFinally(Statement): |
| """Class representing a TryFinally node""" |
| |
| |
| class Tuple(NodeNG): |
| """Class representing a Tuple node""" |
| |
| |
| class UnaryOp(NodeNG): |
| """Class representing an UnaryOp node""" |
| |
| |
| class While(Statement): |
| """Class representing a While node""" |
| |
| |
| class With(Statement): |
| """Class representing a With node""" |
| |
| |
| class WithItem(NodeNG): |
| """Class representing a WithItem node""" |
| |
| |
| class AsyncWith(With): |
| """Asynchronous `with` built with the `async` keyword.""" |
| |
| |
| class Yield(NodeNG): |
| """Class representing a Yield node""" |
| |
| |
| class YieldFrom(Yield): |
| """Class representing a YieldFrom node. """ |
| |
| |
| class DictUnpack(NodeNG): |
| """Represents the unpacking of dicts into dicts using PEP 448.""" |
| |
| |
| class Module(NodeNG): |
| """Class representing a Module node.""" |
| |
| |
| class GeneratorExp(NodeNG): |
| """Class representing a GeneratorExp node.""" |
| |
| |
| class DictComp(NodeNG): |
| """Class representing a generator comprehension node.""" |
| |
| |
| class SetComp(NodeNG): |
| """Class representing a set comprehension node.""" |
| |
| |
| class ListComp(NodeNG): |
| """Class representing a list comprehension node.""" |
| |
| |
| class Lambda(NodeNG): |
| """Class representing a lambda comprehension node.""" |
| |
| |
| class AsyncFunctionDef(NodeNG): |
| """Class representing an asynchronous function node.""" |
| |
| |
| class ClassDef(Statement, NodeNG): |
| """Class representing a class definition node.""" |
| |
| |
| class FunctionDef(Statement, Lambda): |
| """Class representing a function node.""" |
| |
| |
| class InterpreterObject(NodeNG): |
| pass |
| |
| |
| class ReservedName(NodeNG): |
| pass |
| |
| |
| class Unknown(NodeNG): |
| pass |
| |
| |
| class Empty(NodeNG): |
| """Empty nodes represents the lack of something |
| |
| For instance, they can be used to represent missing annotations |
| or defaults for arguments or anything where None is a valid |
| value. |
| """ |
| |
| class FormattedValue(NodeNG): |
| """Represents a PEP 498 string formatting""" |
| |
| |
| class JoinedStr(NodeNG): |
| """Represents a list of string expressions to be joined.""" |