Skip to content

Commit

Permalink
Minor typing changes (#962)
Browse files Browse the repository at this point in the history
  • Loading branch information
AttackingOrDefending authored May 23, 2024
1 parent 7bd4e84 commit 4fc09ac
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
2 changes: 0 additions & 2 deletions homemade.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
With these classes, bot makers will not have to implement the UCI or XBoard interfaces themselves.
"""

from __future__ import annotations
import chess
from chess.engine import PlayResult, Limit
import random
Expand Down
27 changes: 13 additions & 14 deletions lib/conversation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Allows lichess-bot to send messages to the chat."""
from __future__ import annotations
import logging
import test_bot.lichess
from lib import model
Expand All @@ -15,6 +14,19 @@
logger = logging.getLogger(__name__)


class ChatLine:
"""Information about the message."""

def __init__(self, message_info: GameEventType) -> None:
"""Information about the message."""
self.room = message_info["room"]
"""Whether the message was sent in the chat room or in the spectator room."""
self.username = message_info["username"]
"""The username of the account that sent the message."""
self.text = message_info["text"]
"""The message sent."""


class Conversation:
"""Enables the bot to communicate with its opponent and the spectators."""

Expand Down Expand Up @@ -91,16 +103,3 @@ def send_message(self, room: str, message: str) -> None:
"""Send the message to the chat."""
if message:
self.send_reply(ChatLine({"room": room, "username": "", "text": ""}), message)


class ChatLine:
"""Information about the message."""

def __init__(self, message_info: GameEventType) -> None:
"""Information about the message."""
self.room = message_info["room"]
"""Whether the message was sent in the chat room or in the spectator room."""
self.username = message_info["username"]
"""The username of the account that sent the message."""
self.text = message_info["text"]
"""The message sent."""
1 change: 1 addition & 0 deletions lib/engine_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ def __getattr__(self, method_name: str) -> Any:
"""Provide the property `self.engine`."""
main_engine = self.main_engine

# These types aren't tested by mypy.
def method(*args: ENGINE_INPUT_ARGS_TYPE, **kwargs: ENGINE_INPUT_KWARGS_TYPE) -> Any:
nonlocal main_engine
nonlocal method_name
Expand Down
4 changes: 2 additions & 2 deletions lib/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def is_supported_time_control(self, challenge_cfg: Configuration) -> bool:
increment_min: int = challenge_cfg.min_increment
base_max: int = challenge_cfg.max_base
base_min: int = challenge_cfg.min_base
days_max: int = challenge_cfg.max_days
days_min: int = challenge_cfg.min_days
days_max: float = challenge_cfg.max_days
days_min: float = challenge_cfg.min_days

if self.speed not in speeds:
return False
Expand Down

0 comments on commit 4fc09ac

Please sign in to comment.