Skip to content

Commit

Permalink
Merge pull request #457 from pikers/msgspec-default-factories
Browse files Browse the repository at this point in the history
Use new msgspec default factories
  • Loading branch information
Guillermo Rodriguez authored Feb 12, 2023
2 parents 1f20819 + 5ca4536 commit f0b17cb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
6 changes: 4 additions & 2 deletions piker/clearing/_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
Literal,
)

from msgspec import field

from ..data._source import Symbol
from ..data.types import Struct

Expand Down Expand Up @@ -250,9 +252,9 @@ class BrokerdStatus(Struct):
# external: bool = False

# XXX: not required schema as of yet
broker_details: dict = {
broker_details: dict = field(default_factory=lambda: {
'name': '',
}
})


class BrokerdFill(Struct):
Expand Down
6 changes: 4 additions & 2 deletions piker/ui/_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import trio
import pyqtgraph as pg

from msgspec import field

# from .. import brokers
from ..data.feed import (
open_feed,
Expand Down Expand Up @@ -151,14 +153,14 @@ class DisplayState(Struct):
hist_last_price_sticky: YAxisLabel

# misc state tracking
vars: dict[str, Any] = {
vars: dict[str, Any] = field(default_factory=lambda: {
'tick_margin': 0,
'i_last': 0,
'i_last_append': 0,
'last_mx_vlm': 0,
'last_mx': 0,
'last_mn': 0,
}
})

vlm_chart: Optional[ChartPlotWidget] = None
vlm_sticky: Optional[YAxisLabel] = None
Expand Down
3 changes: 2 additions & 1 deletion piker/ui/_pathops.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import numpy as np
from numpy.lib import recfunctions as rfn
from numba import njit, float64, int64 # , optional
from msgspec import field
# import pyqtgraph as pg
# from PyQt5 import QtGui
# from PyQt5.QtCore import QLineF, QPointF
Expand Down Expand Up @@ -488,7 +489,7 @@ def format_xy_nd_to_1d(

class OHLCBarsFmtr(IncrementalFormatter):

fields: list[str] = ['open', 'high', 'low', 'close']
fields: list[str] = field(default_factory=lambda: ['open', 'high', 'low', 'close'])

def allocate_xy_nd(
self,
Expand Down

0 comments on commit f0b17cb

Please sign in to comment.