How to use the astroid.bases.NodeNG function in astroid

To help you get started, we’ve selected a few astroid examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ethanchewy / PythonBuddy / venv / lib / python2.7 / site-packages / astroid / node_classes.py View on Github external
_stmts = []
                _stmt_parents = []
                continue
            if not are_exclusive(self, node):
                _stmts.append(node)
                _stmt_parents.append(stmt.parent)
        return _stmts


# Name classes

class AssignName(LookupMixIn, mixins.ParentAssignTypeMixin, bases.NodeNG):
    """class representing an AssName node"""


class DelName(LookupMixIn, mixins.ParentAssignTypeMixin, bases.NodeNG):
    """class representing a DelName node"""


class Name(LookupMixIn, bases.NodeNG):
    """class representing a Name node"""


class Arguments(mixins.AssignTypeMixin, bases.NodeNG):
    """class representing an Arguments node"""
    if six.PY3:
        # Python 3.4+ uses a different approach regarding annotations,
        # each argument is a new class, _ast.arg, which exposes an
        # 'annotation' attribute. In astroid though, arguments are exposed
        # as is in the Arguments node and the only way to expose annotations
        # is by using something similar with Python 3.3:
        #  - we expose 'varargannotation' and 'kwargannotation' of annotations
github pylava / pylava_pylint / pylama_pylint / astroid / node_classes.py View on Github external
optional_assign = True
    @cachedproperty
    def blockstart_tolineno(self):
        return self.iter.tolineno


class From(FromImportMixIn, Statement):
    """class representing a From node"""

    def __init__(self, fromname, names, level=0):
        self.modname = fromname
        self.names = names
        self.level = level

class Getattr(NodeNG):
    """class representing a Getattr node"""
    _astroid_fields = ('expr',)
    expr = None


class Global(Statement):
    """class representing a Global node"""

    def __init__(self, names):
        self.names = names

    def _infer_name(self, frame, name):
        return name


class If(BlockRangeMixIn, Statement):
github ethanchewy / PythonBuddy / venv / lib / python2.7 / site-packages / astroid / node_classes.py View on Github external
return self.items[-1][0].tolineno

    def get_children(self):
        for expr, var in self.items:
            yield expr
            if var:
                yield var
        for elt in self.body:
            yield elt


class AsyncWith(With):
    """Asynchronous `with` built with the `async` keyword."""


class Yield(bases.NodeNG):
    """class representing a Yield node"""
    _astroid_fields = ('value',)
    value = None

class YieldFrom(Yield):
    """ Class representing a YieldFrom node. """


class DictUnpack(bases.NodeNG):
    """Represents the unpacking of dicts into dicts using PEP 448."""


# constants ##############################################################

CONST_CLS = {
    list: List,
github pylava / pylava_pylint / pylama_pylint / astroid / node_classes.py View on Github external
def raises_not_implemented(self):
        if not self.exc:
            return
        for name in self.exc.nodes_of_class(Name):
            if name.name == 'NotImplementedError':
                return True


class Return(Statement):
    """class representing a Return node"""
    _astroid_fields = ('value',)
    value = None


class Set(NodeNG, Instance, ParentAssignTypeMixin):
    """class representing a Set node"""
    _astroid_fields = ('elts',)

    def __init__(self, elts=None):
        if elts is None:
            self.elts = []
        else:
            self.elts = [const_factory(e) for e in elts]

    def pytype(self):
        return '%s.set' % BUILTINS

    def itered(self):
        return self.elts
github pylava / pylava_pylint / pylama_pylint / astroid / node_classes.py View on Github external
def const_factory(value):
    """return an astroid node for a python value"""
    # XXX we should probably be stricter here and only consider stuff in
    # CONST_CLS or do better treatment: in case where value is not in CONST_CLS,
    # we should rather recall the builder on this value than returning an empty
    # node (another option being that const_factory shouldn't be called with something
    # not in CONST_CLS)
    assert not isinstance(value, NodeNG)
    try:
        return CONST_CLS[value.__class__](value)
    except (KeyError, AttributeError):
        node = EmptyNode()
        node.object = value
        return node
github marslo / myvim / Configurations / Offline_Packages / bundle / python-mode / pymode / libs / astroid / node_classes.py View on Github external
    @cachedproperty
    def blockstart_tolineno(self):
        return self.test.tolineno

    def block_range(self, lineno):
        """handle block line numbers range for if statements"""
        if lineno == self.body[0].fromlineno:
            return lineno, lineno
        if lineno <= self.body[-1].tolineno:
            return lineno, self.body[-1].tolineno
        return self._elsed_block_range(lineno, self.orelse,
                                       self.body[0].fromlineno - 1)


class IfExp(NodeNG):
    """class representing an IfExp node"""
    _astroid_fields = ('test', 'body', 'orelse')
    test = None
    body = None
    orelse = None


class Import(FromImportMixIn, Statement):
    """class representing an Import node"""


class Index(NodeNG):
    """class representing an Index node"""
    _astroid_fields = ('value',)
    value = None
github pylava / pylava_pylint / pylama_pylint / astroid / node_classes.py View on Github external
_astroid_fields = ('elts',)

    def __init__(self, elts=None):
        if elts is None:
            self.elts = []
        else:
            self.elts = [const_factory(e) for e in elts]

    def pytype(self):
        return '%s.set' % BUILTINS

    def itered(self):
        return self.elts


class Slice(NodeNG):
    """class representing a Slice node"""
    _astroid_fields = ('lower', 'upper', 'step')
    lower = None
    upper = None
    step = None

class Starred(NodeNG, ParentAssignTypeMixin):
    """class representing a Starred node"""
    _astroid_fields = ('value',)
    value = None


class Subscript(NodeNG):
    """class representing a Subscript node"""
    _astroid_fields = ('value', 'slice')
    value = None
github pylava / pylava_pylint / pylama_pylint / astroid / node_classes.py View on Github external
"""class representing an AssName node"""


class DelName(LookupMixIn, ParentAssignTypeMixin, NodeNG):
    """class representing a DelName node"""


class Name(LookupMixIn, NodeNG):
    """class representing a Name node"""




#####################   node classes   ########################################

class Arguments(NodeNG, AssignTypeMixin):
    """class representing an Arguments node"""
    if PY3K:
        # Python 3.4+ uses a different approach regarding annotations,
        # each argument is a new class, _ast.arg, which exposes an
        # 'annotation' attribute. In astroid though, arguments are exposed
        # as is in the Arguments node and the only way to expose annotations
        # is by using something similar with Python 3.3:
        #  - we expose 'varargannotation' and 'kwargannotation' of annotations
        #    of varargs and kwargs.
        #  - we expose 'annotation', a list with annotations for
        #    for each normal argument. If an argument doesn't have an
        #    annotation, its value will be None.

        _astroid_fields = ('args', 'defaults', 'kwonlyargs',
                           'kw_defaults', 'annotations',
                           'varargannotation', 'kwargannotation')
github ethanchewy / PythonBuddy / venv / lib / python2.7 / site-packages / astroid / node_classes.py View on Github external
test = None
    fail = None

class Assign(bases.Statement, mixins.AssignTypeMixin):
    """class representing an Assign node"""
    _astroid_fields = ('targets', 'value',)
    targets = None
    value = None

class AugAssign(bases.Statement, mixins.AssignTypeMixin):
    """class representing an AugAssign node"""
    _astroid_fields = ('target', 'value',)
    target = None
    value = None

class Repr(bases.NodeNG):
    """class representing a Backquote node"""
    _astroid_fields = ('value',)
    value = None

class BinOp(bases.NodeNG):
    """class representing a BinOp node"""
    _astroid_fields = ('left', 'right',)
    left = None
    right = None

class BoolOp(bases.NodeNG):
    """class representing a BoolOp node"""
    _astroid_fields = ('values',)
    values = None

class Break(bases.Statement):
github ethanchewy / PythonBuddy / venv / lib / python2.7 / site-packages / astroid / node_classes.py View on Github external
class Set(_BaseContainer):
    """class representing a Set node"""

    def pytype(self):
        return '%s.set' % BUILTINS


class Slice(bases.NodeNG):
    """class representing a Slice node"""
    _astroid_fields = ('lower', 'upper', 'step')
    lower = None
    upper = None
    step = None

class Starred(mixins.ParentAssignTypeMixin, bases.NodeNG):
    """class representing a Starred node"""
    _astroid_fields = ('value',)
    value = None


class Subscript(bases.NodeNG):
    """class representing a Subscript node"""
    _astroid_fields = ('value', 'slice')
    value = None
    slice = None


class TryExcept(mixins.BlockRangeMixIn, bases.Statement):
    """class representing a TryExcept node"""
    _astroid_fields = ('body', 'handlers', 'orelse',)
    body = None