| 479 | |
| 480 | |
| 481 | class RandChoice(RandField[Any]): |
| 482 | def __init__(self, *args): |
| 483 | # type: (*Any) -> None |
| 484 | if not args: |
| 485 | raise TypeError("RandChoice needs at least one choice") |
| 486 | self._choice = list(args) |
| 487 | |
| 488 | def _command_args(self): |
| 489 | # type: () -> str |
| 490 | return ", ".join(self._choice) |
| 491 | |
| 492 | def _fix(self): |
| 493 | # type: () -> Any |
| 494 | return random.choice(self._choice) |
| 495 | |
| 496 | |
| 497 | _S = TypeVar("_S", bytes, str) |