Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new msgspec default factories #457

Merged
merged 1 commit into from
Feb 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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