From f0a346dcc3a5c2057f9b0b515b96b91679843c0b Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Wed, 24 May 2023 17:25:23 -0400 Subject: [PATCH] Some linting fixes after trying out `ruff` --- piker/accounting/cli.py | 9 ++++++++- piker/brokers/kraken/api.py | 2 +- piker/data/history.py | 4 ++-- piker/service/marketstore.py | 7 ++++--- piker/ui/_lines.py | 4 ++-- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/piker/accounting/cli.py b/piker/accounting/cli.py index 76cbc1ab..ee91d1b3 100644 --- a/piker/accounting/cli.py +++ b/piker/accounting/cli.py @@ -28,6 +28,7 @@ import tractor import trio import typer +from ..log import get_logger from ..service import ( open_piker_runtime, ) @@ -102,6 +103,7 @@ def sync( "-l", ), ): + log = get_logger(loglevel) console = Console() try: @@ -134,6 +136,10 @@ def sync( tractor.open_nursery() as an, ): + log.info( + f'Piker runtime up as {actor.uid}@{sockaddr}' + ) + portal = await an.start_actor( loglevel=loglevel, debug_mode=pdb, @@ -162,9 +168,10 @@ def sync( async with ( open_trades_endpoint as ( brokerd_ctx, - (positions, accounts,), + (positions, accounts), ), ): + assert len(accounts) == 1 summary: str = ( '[dim underline]Piker Position Summary[/] ' f'[dim blue underline]{brokername}[/]' diff --git a/piker/brokers/kraken/api.py b/piker/brokers/kraken/api.py index 24330638..1ebdb759 100644 --- a/piker/brokers/kraken/api.py +++ b/piker/brokers/kraken/api.py @@ -296,7 +296,7 @@ class Client: for bs_mktid, info in assets.items(): altname = self._altnames[bs_mktid] = info['altname'] - aclass = info['aclass'] + aclass: str = info['aclass'] self.assets[bs_mktid] = Asset( name=altname.lower(), diff --git a/piker/data/history.py b/piker/data/history.py index 28a4590e..ebfe8c65 100644 --- a/piker/data/history.py +++ b/piker/data/history.py @@ -41,7 +41,6 @@ import numpy as np from .. import config from ..accounting import ( MktPair, - unpack_fqme, ) from ._util import ( log, @@ -110,6 +109,7 @@ async def start_backfill( async with mod.open_history_client( mkt, ) as (hist, config): + log.info(f'{mod} history client returned backfill config: {config}') # get latest query's worth of history all the way # back to what is recorded in the tsdb @@ -326,7 +326,7 @@ async def start_backfill( f'{start_dt} -> {end_dt}' ) - if mkt.dst.atype != 'crypto': + if mkt.dst.atype not in {'crypto', 'crypto_currency'}: # for now, our table key schema is not including # the dst[/src] source asset token. col_sym_key: str = mkt.get_fqme( diff --git a/piker/service/marketstore.py b/piker/service/marketstore.py index 68b9e953..ac0ad0a4 100644 --- a/piker/service/marketstore.py +++ b/piker/service/marketstore.py @@ -26,7 +26,6 @@ from __future__ import annotations from contextlib import asynccontextmanager as acm from datetime import datetime -from functools import partial from pprint import pformat from typing import ( Any, @@ -59,6 +58,7 @@ from ._util import ( log, # sub-sys logger get_console_log, ) +from . import Services from ..data.feed import maybe_open_feed from .._profile import Profiler from .. import config @@ -260,7 +260,7 @@ async def start_ahab_daemon( ep_kwargs={'user_config': conf}, loglevel=loglevel, ) as ( - ctn_ready, + _, config, (cid, pid), ): @@ -583,6 +583,7 @@ class Storage: client = self.client syms = await client.list_symbols() if key not in syms: + await tractor.breakpoint() raise KeyError(f'`{key}` table key not found in\n{syms}?') tbk = mk_tbk(( @@ -743,7 +744,7 @@ async def open_tsdb_client( touch_if_dne=True, ) tsdbconf = rootconf['network'].get('tsdb') - backend = tsdbconf.pop('backend') + # backend = tsdbconf.pop('backend') async with ( open_storage_client( **tsdbconf, diff --git a/piker/ui/_lines.py b/piker/ui/_lines.py index 6f64a349..62ce9de1 100644 --- a/piker/ui/_lines.py +++ b/piker/ui/_lines.py @@ -123,8 +123,8 @@ class LevelLine(pg.InfiniteLine): self._track_cursor: bool = False self.always_show_labels = always_show_labels - self._on_drag_start = lambda l: None - self._on_drag_end = lambda l: None + self._on_drag_start = lambda lvln: None + self._on_drag_end = lambda lvln: None self._y_incr_mult = float(1 / chart.linked.mkt.size_tick) self._right_end_sc: float = 0