def _get_immediate_cls_attr(cls, attrname, strict=False):
    """return an attribute of the class that is either present directly
    on the class, e.g. not on a superclass, or is from a superclass but
    this superclass is a mixin, that is, not a descendant of
    the declarative base.

    This is used to detect attributes that indicate something about
    a mapped class independently from any mapped classes that it may
    inherit from.

    """
    if not issubclass(cls, object):
        return None
    for base in cls.__mro__:
        _is_declarative_inherits = hasattr(base, '_decl_class_registry')
        if attrname in base.__dict__ and (base is cls or (base in cls.
            __bases__ if strict else True) and not _is_declarative_inherits):
            return getattr(base, attrname)
    else:
        return None
