From 4fc09ac91644a209ea76fe39424c7e6c92e91bfe Mon Sep 17 00:00:00 2001 From: Ioannis Pantidis <40605232+AttackingOrDefending@users.noreply.github.com> Date: Thu, 23 May 2024 21:23:53 +0300 Subject: [PATCH] Minor typing changes (#962) --- homemade.py | 2 -- lib/conversation.py | 27 +++++++++++++-------------- lib/engine_wrapper.py | 1 + lib/model.py | 4 ++-- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/homemade.py b/homemade.py index 279a5d857..a16a72dec 100644 --- a/homemade.py +++ b/homemade.py @@ -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 diff --git a/lib/conversation.py b/lib/conversation.py index 4f2b0a6cf..bbc363b3c 100644 --- a/lib/conversation.py +++ b/lib/conversation.py @@ -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 @@ -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.""" @@ -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.""" diff --git a/lib/engine_wrapper.py b/lib/engine_wrapper.py index 8edd2e62f..470b9562b 100644 --- a/lib/engine_wrapper.py +++ b/lib/engine_wrapper.py @@ -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 diff --git a/lib/model.py b/lib/model.py index 53652e442..048716a01 100644 --- a/lib/model.py +++ b/lib/model.py @@ -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