def _instance_callable(obj):
    """Given an object, return True if the object is callable.
    For classes, return True if instances would be callable."""
    if not isinstance(obj, type):
        return getattr(obj, '__call__', None) is not None
    for base in ((obj,) + obj.__mro__):
        if base.__dict__.get('__call__') is not None:
            return True
    return False
