From f210a478c64f03e2d524f74878c80032a6ce84e4 Mon Sep 17 00:00:00 2001 From: goodboy Date: Mon, 30 Mar 2026 13:25:41 -0400 Subject: [PATCH] Move `reg_err_types` imports to module-level Hoist inline `from tractor._exceptions import reg_err_types` calls up to the module-level import block across 5 files so they follow normal import ordering. Other, - `kraken/broker.py`: same; also add `ConfigurationError` import and raise on missing `src_fiat` config field instead of `KeyError`. - `storage/__init__.py`: same; also switch from relative to absolute `piker.*` imports and reorder the import block. - comment out stray `await tractor.pause()` in binance `feed.py`. (this commit msg was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code --- piker/brokers/binance/feed.py | 3 ++- piker/brokers/kraken/api.py | 2 +- piker/brokers/kraken/broker.py | 12 ++++++++++-- piker/data/validate.py | 2 +- piker/service/marketstore.py | 2 +- piker/storage/__init__.py | 13 +++++++------ 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/piker/brokers/binance/feed.py b/piker/brokers/binance/feed.py index 654252e2..5a0a4175 100644 --- a/piker/brokers/binance/feed.py +++ b/piker/brokers/binance/feed.py @@ -383,7 +383,8 @@ async def get_mkt_info( if not mkt_mode: mkt_mode: str = f'{venue_lower}_futes' - await tractor.pause() + # tracing + # await tractor.pause() async with open_cached_client( 'binance', diff --git a/piker/brokers/kraken/api.py b/piker/brokers/kraken/api.py index fbf9d6a9..92297393 100644 --- a/piker/brokers/kraken/api.py +++ b/piker/brokers/kraken/api.py @@ -35,6 +35,7 @@ import hashlib import hmac import base64 import tractor +from tractor._exceptions import reg_err_types import trio from piker import config @@ -118,7 +119,6 @@ class InvalidKey(ValueError): ''' -from tractor._exceptions import reg_err_types reg_err_types([InvalidKey]) diff --git a/piker/brokers/kraken/broker.py b/piker/brokers/kraken/broker.py index 303a923e..027b92b7 100644 --- a/piker/brokers/kraken/broker.py +++ b/piker/brokers/kraken/broker.py @@ -36,6 +36,7 @@ from typing import ( from bidict import bidict import trio import tractor +from tractor._exceptions import reg_err_types from piker.accounting import ( Position, @@ -45,6 +46,9 @@ from piker.accounting import ( open_trade_ledger, open_account, ) +from piker.config import ( + ConfigurationError, +) from piker.clearing import( OrderDialogs, ) @@ -97,7 +101,7 @@ MsgUnion = Union[ class TooFastEdit(Exception): 'Edit requests faster then api submissions' -from tractor._exceptions import reg_err_types + reg_err_types([TooFastEdit]) @@ -464,7 +468,11 @@ async def open_trade_dialog( # (much like the web UI let's you set an "account currency") # such that all positions (nested or flat) will be translated to # this source currency's terms. - src_fiat = client.conf['src_fiat'] + src_fiat = client.conf.get('src_fiat') + if not src_fiat: + raise ConfigurationError( + 'No `src_fiat: str` field defined in `brokers.toml`' + ) # auth required block acctid = client._name diff --git a/piker/data/validate.py b/piker/data/validate.py index fc82c799..38bd4086 100644 --- a/piker/data/validate.py +++ b/piker/data/validate.py @@ -28,13 +28,13 @@ from typing import ( ) from msgspec import field +from tractor._exceptions import reg_err_types from piker.types import Struct from piker.accounting import ( Asset, MktPair, ) -from tractor._exceptions import reg_err_types from ._util import log diff --git a/piker/service/marketstore.py b/piker/service/marketstore.py index c21a8bad..c842a5bd 100644 --- a/piker/service/marketstore.py +++ b/piker/service/marketstore.py @@ -42,6 +42,7 @@ from msgspec.msgpack import ( # import pyqtgraph as pg import numpy as np import tractor +from tractor._exceptions import reg_err_types from trio_websocket import open_websocket_url from anyio_marketstore import ( # noqa open_marketstore_client, @@ -382,7 +383,6 @@ def quote_to_marketstore_structarray( class MarketStoreError(Exception): "Generic marketstore client error" -from tractor._exceptions import reg_err_types reg_err_types([MarketStoreError]) diff --git a/piker/storage/__init__.py b/piker/storage/__init__.py index 90d1f80c..3256dbf2 100644 --- a/piker/storage/__init__.py +++ b/piker/storage/__init__.py @@ -42,15 +42,17 @@ from typing import ( ) import numpy as np +from tractor._exceptions import reg_err_types -from .. import config -from ..service import ( - check_for_service, -) -from ..log import ( +from piker import config +from piker.log import ( get_logger, get_console_log, ) +from piker.service import ( + check_for_service, +) + subsys: str = 'piker.storage' log = get_logger(subsys) @@ -151,7 +153,6 @@ class StorageConnectionError(ConnectionError): ''' -from tractor._exceptions import reg_err_types reg_err_types([ TimeseriesNotFound, StorageConnectionError,