예제 #1
0
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