Skip to content

Commit 53eb0f9

Browse files
S1M0N38claude
andcommitted
refactor(examples): standardize imports and improve type annotations
- Update example and replay bots to use balatrobot imports - Add proper return type annotation to connect() method - Improve send_message() parameter handling with None default Co-Authored-By: Claude <[email protected]>
1 parent e67182a commit 53eb0f9

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

bots/example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import logging
44

5-
from src.balatrobot.client import BalatroClient
6-
from src.balatrobot.exceptions import BalatroError
5+
from balatrobot.client import BalatroClient
6+
from balatrobot.exceptions import BalatroError
77

88
logger = logging.getLogger(__name__)
99
logging.basicConfig(level=logging.INFO)

bots/replay.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import sys
66
from pathlib import Path
77

8-
from src.balatrobot.client import BalatroClient
9-
from src.balatrobot.exceptions import BalatroError, ConnectionFailedError
8+
from balatrobot.client import BalatroClient
9+
from balatrobot.exceptions import BalatroError, ConnectionFailedError
1010

1111
logger = logging.getLogger(__name__)
1212
logging.basicConfig(level=logging.INFO)

src/balatrobot/client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def __exit__(self, exc_type, exc_val, exc_tb) -> None:
4545
"""Exit context manager and disconnect from the game."""
4646
self.disconnect()
4747

48-
def connect(self):
48+
def connect(self) -> None:
4949
"""Connect to Balatro TCP server
5050
5151
Raises:
@@ -82,7 +82,7 @@ def disconnect(self) -> None:
8282
self._socket = None
8383
self._connected = False
8484

85-
def send_message(self, name: str, arguments: dict = {}) -> dict:
85+
def send_message(self, name: str, arguments: dict | None = None) -> dict:
8686
"""Send JSON message to Balatro and receive response
8787
8888
Args:
@@ -96,6 +96,9 @@ def send_message(self, name: str, arguments: dict = {}) -> dict:
9696
ConnectionFailedError: If not connected to the game
9797
BalatroError: If the API returns an error
9898
"""
99+
if arguments is None:
100+
arguments = {}
101+
99102
if not self._connected or not self._socket:
100103
raise ConnectionFailedError(
101104
"Not connected to the game API",

0 commit comments

Comments
 (0)