Skip to content

Commit 4e05c5a

Browse files
committed
Fix CI: formatting and test alignment
- Format wallet.py with black - Add TYPE_CHECKING import for LLMClient type hint - Update test to match current behavior (require explicit wallet setup)
1 parent a816e4d commit 4e05c5a

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

blockrun_llm/wallet.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,17 @@
77
- Generates EIP-681 QR codes for easy MetaMask funding
88
"""
99

10+
from __future__ import annotations
11+
1012
import os
1113
from pathlib import Path
12-
from typing import Optional, Tuple
14+
from typing import TYPE_CHECKING, Optional, Tuple
15+
1316
from eth_account import Account
1417

18+
if TYPE_CHECKING:
19+
from blockrun_llm import LLMClient
20+
1521
# Wallet storage location
1622
WALLET_DIR = Path.home() / ".blockrun"
1723
WALLET_FILE = WALLET_DIR / ".session" # Wallet key file
@@ -446,6 +452,7 @@ def setup_agent_wallet(silent: bool = False) -> "LLMClient":
446452

447453
# Import here to avoid circular import
448454
from .client import LLMClient
455+
449456
return LLMClient(private_key=key)
450457

451458

tests/unit/test_client.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,15 @@ def test_init_with_valid_key(self):
1818
assert client is not None
1919
assert client.get_wallet_address().startswith("0x")
2020

21-
def test_init_missing_key_auto_creates_wallet(self, monkeypatch, tmp_path):
22-
"""Should auto-create wallet when private key is missing."""
21+
def test_init_missing_key_raises_error(self, monkeypatch, tmp_path):
22+
"""Should raise ValueError when no wallet configured."""
2323
monkeypatch.delenv("BLOCKRUN_WALLET_KEY", raising=False)
2424
monkeypatch.delenv("BASE_CHAIN_WALLET_KEY", raising=False)
25-
# Mock wallet directory to use tmp_path
26-
monkeypatch.setattr("blockrun_llm.wallet.WALLET_DIR", tmp_path)
27-
monkeypatch.setattr("blockrun_llm.wallet.WALLET_FILE", tmp_path / ".session")
2825
# Mock load_wallet to return None (no session file)
2926
monkeypatch.setattr("blockrun_llm.wallet.load_wallet", lambda: None)
30-
# Should auto-create wallet instead of raising ValueError
31-
client = LLMClient(private_key=None)
32-
# Verify wallet was created
33-
assert client.get_wallet_address().startswith("0x")
27+
# Should raise ValueError with helpful message
28+
with pytest.raises(ValueError, match="No wallet configured"):
29+
LLMClient(private_key=None)
3430

3531
def test_init_invalid_key_format(self):
3632
"""Should raise ValueError for invalid key format (after 0x normalization)."""

0 commit comments

Comments
 (0)