def _is_document_field(node):
    """Checks if a node is a valid document field."""
    try:
        inf = next(node.get_children()).inferred()[0]
    except InferenceError:
        return False
    return node_is_document(inf) and name_is_from_model(node.attrname)
示例#2
0
    def visit_call(self, node):

        children = node.get_children()

        attr = next(children)
        meth = safe_infer(attr)
        if meth:
            return False

        last_child = attr.last_child()

        if last_child is None:
            return False

        attr_self = safe_infer(last_child)
        cls = getattr(attr_self, '_proxied', None)

        if node_is_subclass(
                cls, *
                DOCUMENT_BASES) and not name_is_from_model(attr.attrname):
            self.add_message('no-member',
                             node=attr,
                             args=('Document', cls.name, attr.attrname, ''))
示例#3
0
def test_name_is_from_model_false():
    attrname = 'who_are_you'
    r = utils.name_is_from_model(attrname)
    assert r is False
示例#4
0
def test_name_is_from_model_true():
    attrname = 'delete'
    r = utils.name_is_from_model(attrname)
    assert r is True