code: def set_piece_at(self, square: Square, piece: Optional[Piece], promoted: bool = False) -> None:
          
          if piece is None:
              self._remove_piece_at(square)
          else:
              self._set_piece_at(square, piece.piece_type, piece.color, promoted)
docs: Sets a piece at the given square.
  
          An existing piece is replaced. Setting *piece* to ``None`` is
          equivalent to :func:`~chess.Board.remove_piece_at()`.