summaryrefslogtreecommitdiff
path: root/swiftstory/client.py
diff options
context:
space:
mode:
authorOlivier Gayot <olivier.gayot@sigexec.com>2021-12-29 17:05:21 +0100
committerOlivier Gayot <olivier.gayot@sigexec.com>2021-12-29 17:06:29 +0100
commit95ca11e98c47c3e8e57093c37134a6f51bcb6f30 (patch)
tree4c10504aee30dab96e6d5836f0f35f9d6a6a9810 /swiftstory/client.py
parent8d242a5e6c090ee8165b36fea6520d533269518e (diff)
Add type hinting everywhere so we can enable strict mypy options
Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
Diffstat (limited to 'swiftstory/client.py')
-rw-r--r--swiftstory/client.py7
1 files changed, 4 insertions, 3 deletions
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: