docs: def direction(direction, allow_bi=False):
      """Validate that the given direction is one of the allowed constants.
  
      If ``allow_bi`` is ``True`` then ``Direction.BIDIRECTIONAL`` is
      acceptable.
      """
      valid = [Direction.CAUSE, Direction.EFFECT]
      if allow_bi:
          valid.append(Direction.BIDIRECTIONAL)
  
      if direction not in valid:
          raise ValueError('`direction` must be one of {}'.format(valid))
  
      return True