Skip to content

Commit d2051e3

Browse files
committed
Refactor market inspector page and update imports
- Renamed the import for the market inspector page from `market_inspector` to `market_inspector_page` for consistency with naming conventions. - Resolved some linter/type errors, suppressed warnings in market_inspector_page.py
1 parent 461096c commit d2051e3

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from page.deposits_page import deposits_page
1414
from page.health import health_page
1515
from page.liquidation_curves_page import liquidation_curves_page
16-
from page.market_inspector import market_inspector_page
16+
from page.market_inspector_page import market_inspector_page
1717
from page.orderbook import orderbook_page
1818
from page.pnl_page import pnl_page
1919
from page.price_shock import price_shock_cached_page

src/page/market_inspector.py renamed to src/page/market_inspector_page.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import inspect
77
import pandas as pd
88

9-
from anchorpy import Wallet
9+
from anchorpy.provider import Wallet
1010
from dotenv import load_dotenv
1111
from driftpy.drift_client import DriftClient
1212
from driftpy.market_map.market_map import MarketMap
@@ -30,7 +30,7 @@ def format_pubkey(pubkey: str) -> str:
3030
"""Truncate pubkey for display."""
3131
return f"{str(pubkey)[:10]}...{str(pubkey)[-10:]}"
3232

33-
def format_number(number: int, decimals=6) -> str:
33+
def format_number(number: int | float, decimals=6) -> str:
3434
"""Format large numbers for better readability."""
3535
return f"{number / (10 ** decimals):,.6f}"
3636

@@ -146,7 +146,7 @@ def display_attribute(market_data, attr_path: str, debug_mode: bool = False):
146146

147147
# If it's a Pubkey or similar
148148
if hasattr(val, '__class__') and val.__class__.__name__ == 'Pubkey':
149-
return f"{attr_path}: {format_pubkey(val)}"
149+
return f"{attr_path}: {format_pubkey(str(val))}"
150150

151151
# If it's an int that might represent a 'price' or 'reserve'
152152
if isinstance(val, int):
@@ -201,7 +201,7 @@ def format_complex_object(attr_name, obj):
201201
if isinstance(attr_val, (int, float)) and any(x in attr_name.lower() for x in ["price", "amount", "balance"]):
202202
formatted_value = format_number(attr_val, 6)
203203
elif hasattr(attr_val, '__class__') and attr_val.__class__.__name__ == 'Pubkey':
204-
formatted_value = format_pubkey(attr_val)
204+
formatted_value = format_pubkey(str(attr_val))
205205
else:
206206
formatted_value = str(attr_val)
207207
result.append(f" • {attr_name}: {formatted_value}")
@@ -228,7 +228,7 @@ def format_complex_object(attr_name, obj):
228228
if isinstance(value, (int, float)) and any(x in name.lower() for x in ["price", "amount", "balance"]):
229229
formatted_value = format_number(value, 6)
230230
elif hasattr(value, '__class__') and value.__class__.__name__ == 'Pubkey':
231-
formatted_value = format_pubkey(value)
231+
formatted_value = format_pubkey(str(value))
232232
elif (hasattr(value, '__class__')
233233
and not isinstance(value, (str, int, float, bool, list, dict))
234234
and hasattr(value, '__dict__')):
@@ -278,7 +278,7 @@ async def _fetch_market_maps():
278278
perp_market_map = MarketMap(
279279
MarketMapConfig(
280280
drift_client.program,
281-
MarketType.Perp(),
281+
MarketType.Perp(), # type: ignore
282282
WebsocketConfig(resub_timeout_ms=10000),
283283
connection,
284284
)
@@ -289,7 +289,7 @@ async def _fetch_market_maps():
289289
spot_market_map = MarketMap(
290290
MarketMapConfig(
291291
drift_client.program,
292-
MarketType.Spot(),
292+
MarketType.Spot(), # type: ignore
293293
WebsocketConfig(resub_timeout_ms=10000),
294294
connection,
295295
)

0 commit comments

Comments
 (0)