|
24 | 24 |
|
25 | 25 | from typing import ClassVar, Callable, Counter, Dict, Generic, Hashable, Iterable, Iterator, List, Literal, Mapping, Optional, SupportsInt, Tuple, Type, TypeVar, Union
|
26 | 26 |
|
| 27 | +if typing.TYPE_CHECKING: |
| 28 | + from typing_extensions import TypeAlias |
| 29 | + |
| 30 | + |
27 | 31 | EnPassantSpec = Literal["legal", "fen", "xfen"]
|
28 | 32 |
|
29 | 33 |
|
30 |
| -Color = bool |
| 34 | +Color: TypeAlias = bool |
31 | 35 | COLORS = [WHITE, BLACK] = [True, False]
|
32 | 36 | ColorName = Literal["white", "black"]
|
33 | 37 | COLOR_NAMES: List[ColorName] = ["black", "white"]
|
34 | 38 |
|
35 |
| -PieceType = int |
| 39 | +PieceType: TypeAlias = int |
36 | 40 | PIECE_TYPES = [PAWN, KNIGHT, BISHOP, ROOK, QUEEN, KING] = range(1, 7)
|
37 | 41 | PIECE_SYMBOLS = [None, "p", "n", "b", "r", "q", "k"]
|
38 | 42 | PIECE_NAMES = [None, "pawn", "knight", "bishop", "rook", "queen", "king"]
|
@@ -157,7 +161,7 @@ class AmbiguousMoveError(ValueError):
|
157 | 161 | """Raised when the attempted move is ambiguous in the current position"""
|
158 | 162 |
|
159 | 163 |
|
160 |
| -Square = int |
| 164 | +Square: TypeAlias = int |
161 | 165 | SQUARES = [
|
162 | 166 | A1, B1, C1, D1, E1, F1, G1, H1,
|
163 | 167 | A2, B2, C2, D2, E2, F2, G2, H2,
|
@@ -233,7 +237,7 @@ def square_mirror(square: Square) -> Square:
|
233 | 237 | SQUARES_180 = [square_mirror(sq) for sq in SQUARES]
|
234 | 238 |
|
235 | 239 |
|
236 |
| -Bitboard = int |
| 240 | +Bitboard: TypeAlias = int |
237 | 241 | BB_EMPTY = 0
|
238 | 242 | BB_ALL = 0xffff_ffff_ffff_ffff
|
239 | 243 |
|
@@ -3816,7 +3820,7 @@ def __repr__(self) -> str:
|
3816 | 3820 | return f"<LegalMoveGenerator at {id(self):#x} ({sans})>"
|
3817 | 3821 |
|
3818 | 3822 |
|
3819 |
| -IntoSquareSet = Union[SupportsInt, Iterable[Square]] |
| 3823 | +IntoSquareSet: TypeAlias = Union[SupportsInt, Iterable[Square]] |
3820 | 3824 |
|
3821 | 3825 | class SquareSet:
|
3822 | 3826 | """
|
|
0 commit comments