From 87698c86edd23badaf1b1ac2490517b6568a69c7 Mon Sep 17 00:00:00 2001 From: kraktus Date: Thu, 28 May 2026 14:32:01 +0200 Subject: [PATCH] variation_san, include a space after the ellipsis for black moves Feel easier to read and also how Lichess write its PGN --- chess/__init__.py | 4 ++-- test.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/chess/__init__.py b/chess/__init__.py index 9ea44f36..a8bc48d1 100644 --- a/chess/__init__.py +++ b/chess/__init__.py @@ -3194,7 +3194,7 @@ def variation_san(self, variation: Iterable[Move]) -> str: """ Given a sequence of moves, returns a string representing the sequence in standard algebraic notation (e.g., ``1. e4 e5 2. Nf3 Nc6`` or - ``37...Bg6 38. fxg6``). + ``37... Bg6 38. fxg6``). The board will not be modified as a result of calling this. @@ -3210,7 +3210,7 @@ def variation_san(self, variation: Iterable[Move]) -> str: if board.turn == WHITE: san.append(f"{board.fullmove_number}. {board.san_and_push(move)}") elif not san: - san.append(f"{board.fullmove_number}...{board.san_and_push(move)}") + san.append(f"{board.fullmove_number}... {board.san_and_push(move)}") else: san.append(board.san_and_push(move)) diff --git a/test.py b/test.py index 228c62f3..8a8e00f4 100755 --- a/test.py +++ b/test.py @@ -779,7 +779,7 @@ def test_variation_san(self): self.assertEqual(fen, board.fen(), msg="Board unchanged by variation_san") board.push(chess.Move.from_uci(variation.pop(0))) var_b = board.variation_san([chess.Move.from_uci(m) for m in variation]) - self.assertEqual(("19...Kxh7 20. Qh5+ Kg8 21. Rg3 Bf8 22. Bg5 Re7 " + self.assertEqual(("19... Kxh7 20. Qh5+ Kg8 21. Rg3 Bf8 22. Bg5 Re7 " "23. Bf6 Nd7 24. Qh6 Nxf6 25. exf6 g6 26. fxe7 Bxe7"), var_b)