'Return True if the instance is associated with this session.
The instance may be pending or persistent within the Session for a
result of True.'

def __contains__(self, instance):

    try:
        state = attributes.instance_state(instance)
    except exc.NO_STATE:
        raise exc.UnmappedInstanceError(instance)
    return self._contains_state(state)
