From 95ca11e98c47c3e8e57093c37134a6f51bcb6f30 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Wed, 29 Dec 2021 17:05:21 +0100 Subject: Add type hinting everywhere so we can enable strict mypy options Signed-off-by: Olivier Gayot --- swiftstory/client.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'swiftstory/client.py') diff --git a/swiftstory/client.py b/swiftstory/client.py index 98ba530..28fd6c0 100644 --- a/swiftstory/client.py +++ b/swiftstory/client.py @@ -3,6 +3,7 @@ import logging from typing import Optional import websockets.exceptions +from websockets.server import WebSocketServerProtocol from swiftstory.game import Game from swiftstory.game_manager import GameManager @@ -14,7 +15,7 @@ class Client: """ Represent a client. A client manages a (web)socket to communicate with the outside world. It also manages the associated player when in a game. """ - def __init__(self, socket, game_manager: GameManager) -> None: + def __init__(self, socket: WebSocketServerProtocol, game_manager: GameManager) -> None: self.game: Optional[Game] = None self.game_manager: GameManager = game_manager @@ -61,7 +62,7 @@ class Client: raise ValueError("Player is None") return self.game.try_collect_cards(self.player) - def designate_card(self, card_id: int) -> str: + def designate_card(self, card_id: Optional[int]) -> str: if self.game is None: raise WrongAction('You have to join a game first') if self.player is None: @@ -91,7 +92,7 @@ class Client: def monitor_player(self) -> None: """ Start monitoring the player for notifications and send them. """ - async def f(): + async def f() -> None: assert self.player is not None while True: try: -- cgit v1.2.3