Skip to content

Commit f286d68

Browse files
committed
Towards pyright compatibility
1 parent 571658b commit f286d68

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

chess/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,7 +1544,7 @@ def from_chess960_pos(cls: Type[BaseBoardT], scharnagl: int) -> BaseBoardT:
15441544

15451545
class _BoardState:
15461546

1547-
def __init__(self, board: BoardT) -> None:
1547+
def __init__(self, board: Board) -> None:
15481548
self.pawns = board.pawns
15491549
self.knights = board.knights
15501550
self.bishops = board.bishops
@@ -1564,7 +1564,7 @@ def __init__(self, board: BoardT) -> None:
15641564
self.halfmove_clock = board.halfmove_clock
15651565
self.fullmove_number = board.fullmove_number
15661566

1567-
def restore(self, board: BoardT) -> None:
1567+
def restore(self, board: Board) -> None:
15681568
board.pawns = self.pawns
15691569
board.knights = self.knights
15701570
board.bishops = self.bishops

chess/engine.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,10 @@ class Score(abc.ABC):
406406
"""
407407

408408
@typing.overload
409+
@abc.abstractmethod
409410
def score(self, *, mate_score: int) -> int: ...
410411
@typing.overload
412+
@abc.abstractmethod
411413
def score(self, *, mate_score: Optional[int] = None) -> Optional[int]: ...
412414
@abc.abstractmethod
413415
def score(self, *, mate_score: Optional[int] = None) -> Optional[int]:
@@ -2120,12 +2122,13 @@ def _new(self, board: chess.Board, game: object, options: ConfigMapping, opponen
21202122
if self.config.get("computer"):
21212123
self.send_line("computer")
21222124

2123-
self.send_line("force")
2125+
self.send_line("force")
21242126

2125-
if new_game:
21262127
fen = root.fen(shredder=board.chess960, en_passant="fen")
21272128
if variant != "normal" or fen != chess.STARTING_FEN or board.chess960:
21282129
self.send_line(f"setboard {fen}")
2130+
else:
2131+
self.send_line("force")
21292132

21302133
# Undo moves until common position.
21312134
common_stack_len = 0

chess/variant.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def _transposition_key(self) -> Hashable:
133133
else:
134134
return super()._transposition_key()
135135

136-
def board_fen(self, promoted: Optional[bool] = None) -> str:
136+
def board_fen(self, *, promoted: Optional[bool] = None) -> str:
137137
if promoted is None:
138138
promoted = self.has_chess960_castling_rights()
139139
return super().board_fen(promoted=promoted)
@@ -799,7 +799,7 @@ def _transposition_key(self) -> Hashable:
799799
return (super()._transposition_key(),
800800
self.remaining_checks[chess.WHITE], self.remaining_checks[chess.BLACK])
801801

802-
def copy(self, stack: Union[bool, int] = True) -> Self:
802+
def copy(self, *, stack: Union[bool, int] = True) -> Self:
803803
board = super().copy(stack=stack)
804804
board.remaining_checks = self.remaining_checks.copy()
805805
if stack:
@@ -1041,7 +1041,7 @@ def set_fen(self, fen: str) -> None:
10411041
self.pockets[chess.WHITE] = white_pocket
10421042
self.pockets[chess.BLACK] = black_pocket
10431043

1044-
def board_fen(self, promoted: Optional[bool] = None) -> str:
1044+
def board_fen(self, *, promoted: Optional[bool] = None) -> str:
10451045
if promoted is None:
10461046
promoted = True
10471047
return super().board_fen(promoted=promoted)
@@ -1051,7 +1051,7 @@ def epd(self, shredder: bool = False, en_passant: chess.EnPassantSpec = "legal",
10511051
board_part, info_part = epd.split(" ", 1)
10521052
return f"{board_part}[{str(self.pockets[chess.WHITE]).upper()}{self.pockets[chess.BLACK]}] {info_part}"
10531053

1054-
def copy(self, stack: Union[bool, int] = True) -> Self:
1054+
def copy(self, *, stack: Union[bool, int] = True) -> Self:
10551055
board = super().copy(stack=stack)
10561056
board.pockets[chess.WHITE] = self.pockets[chess.WHITE].copy()
10571057
board.pockets[chess.BLACK] = self.pockets[chess.BLACK].copy()

0 commit comments

Comments
 (0)