python-chess
python-chess copied to clipboard
Docstring could be more clear
Docstring could be more clear on why this does not work:
board = chess.Board(None)
board.set_piece_at(0, chess.KNIGHT)
Traceback (most recent call last):
File "<python-input-2>", line 1, in <module>
board.set_piece_at(0, chess.KNIGHT)
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python313\Lib\site-packages\chess\__init__.py", line 1816, in set_piece_at
super().set_piece_at(square, piece, promoted=promoted)
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python313\Lib\site-packages\chess\__init__.py", line 1090, in set_piece_at
self._set_piece_at(square, piece.piece_type, piece.color, promoted)
^^^^^^^^^^^^^^^^
AttributeError: 'int' object has no attribute 'piece_type'
Reason: You're feeding a PieceType chess.KNIGHT into a function that needs a Optional[Piece] which you can construct by using Piece(chess.KNIGHT, color)
Docstrings are purely not needed for this.