Skip to content

Commit

Permalink
Adjust .ui modules to new set-style "optional" annots
Browse files Browse the repository at this point in the history
  • Loading branch information
goodboy committed Feb 21, 2023
1 parent 154fad1 commit 020e1ae
Show file tree
Hide file tree
Showing 21 changed files with 127 additions and 130 deletions.
4 changes: 2 additions & 2 deletions piker/ui/_annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
Annotations for ur faces.
"""
from typing import Callable, Optional
from typing import Callable

from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import QPointF, QRectF
Expand Down Expand Up @@ -105,7 +105,7 @@ def __init__(
get_level: Callable[..., float],
size: float = 20,
keep_in_view: bool = True,
on_paint: Optional[Callable] = None,
on_paint: Callable | None = None,

) -> None:

Expand Down
11 changes: 6 additions & 5 deletions piker/ui/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"""
from __future__ import annotations
from functools import lru_cache
from typing import Optional, Callable
from typing import Callable
from math import floor

import numpy as np
Expand Down Expand Up @@ -60,7 +60,8 @@ def __init__(
**kwargs
)

# XXX: pretty sure this makes things slower
# XXX: pretty sure this makes things slower!
# no idea why given we only move labels for the most part?
# self.setCacheMode(QtWidgets.QGraphicsItem.DeviceCoordinateCache)

self.pi = plotitem
Expand Down Expand Up @@ -190,7 +191,7 @@ def __init__(
*args,
min_tick: int = 2,
title: str = '',
formatter: Optional[Callable[[float], str]] = None,
formatter: Callable[[float], str] | None = None,
**kwargs

) -> None:
Expand All @@ -202,8 +203,8 @@ def __init__(
def set_title(
self,
title: str,
view: Optional[ChartView] = None,
color: Optional[str] = None,
view: ChartView | None = None,
color: str | None = None,

) -> Label:
'''
Expand Down
45 changes: 22 additions & 23 deletions piker/ui/_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from __future__ import annotations
from typing import (
Iterator,
Optional,
TYPE_CHECKING,
)

Expand Down Expand Up @@ -102,7 +101,7 @@ def __init__(

super().__init__(parent)

self.search: Optional[SearchWidget] = None
self.search: SearchWidget | None = None

self.hbox = QHBoxLayout(self)
self.hbox.setContentsMargins(0, 0, 0, 0)
Expand All @@ -121,9 +120,9 @@ def __init__(
tuple[LinkedSplits, LinkedSplits],
] = {}

self.hist_linked: Optional[LinkedSplits] = None
self.rt_linked: Optional[LinkedSplits] = None
self._active_cursor: Optional[Cursor] = None
self.hist_linked: LinkedSplits | None = None
self.rt_linked: LinkedSplits | None = None
self._active_cursor: Cursor | None = None

# assigned in the startup func `_async_main()`
self._root_n: trio.Nursery = None
Expand Down Expand Up @@ -367,7 +366,7 @@ class ChartnPane(QFrame):
'''
sidepane: FieldsForm | SearchWidget
hbox: QHBoxLayout
chart: Optional[ChartPlotWidget] = None
chart: ChartPlotWidget | None = None

def __init__(
self,
Expand Down Expand Up @@ -445,7 +444,7 @@ def __init__(
# chart-local graphics state that can be passed to
# a ``graphic_update_cycle()`` call by any task wishing to
# update the UI for a given "chart instance".
self.display_state: Optional[DisplayState] = None
self.display_state: DisplayState | None = None

self._symbol: Symbol = None

Expand Down Expand Up @@ -475,7 +474,7 @@ def symbol(self) -> Symbol:

def set_split_sizes(
self,
prop: Optional[float] = None,
prop: float | None = None,

) -> None:
'''
Expand Down Expand Up @@ -569,11 +568,11 @@ def add_plot(
shm: ShmArray,
flume: Flume,

array_key: Optional[str] = None,
array_key: str | None = None,
style: str = 'line',
_is_main: bool = False,

sidepane: Optional[QWidget] = None,
sidepane: QWidget | None = None,
draw_kwargs: dict = {},

**cpw_kwargs,
Expand Down Expand Up @@ -789,7 +788,7 @@ def add_plot(

def resize_sidepanes(
self,
from_linked: Optional[LinkedSplits] = None,
from_linked: LinkedSplits | None = None,

) -> None:
'''
Expand Down Expand Up @@ -857,7 +856,7 @@ def __init__(
# TODO: load from config
use_open_gl: bool = False,

static_yrange: Optional[tuple[float, float]] = None,
static_yrange: tuple[float, float] | None = None,

parent=None,
**kwargs,
Expand All @@ -872,7 +871,7 @@ def __init__(

# NOTE: must be set bfore calling ``.mk_vb()``
self.linked = linkedsplits
self.sidepane: Optional[FieldsForm] = None
self.sidepane: FieldsForm | None = None

# source of our custom interactions
self.cv = self.mk_vb(name)
Expand Down Expand Up @@ -1035,7 +1034,7 @@ def default_view(
def increment_view(
self,
datums: int = 1,
vb: Optional[ChartView] = None,
vb: ChartView | None = None,

) -> None:
'''
Expand Down Expand Up @@ -1066,8 +1065,8 @@ def increment_view(
def overlay_plotitem(
self,
name: str,
index: Optional[int] = None,
axis_title: Optional[str] = None,
index: int | None = None,
axis_title: str | None = None,
axis_side: str = 'right',
axis_kwargs: dict = {},

Expand Down Expand Up @@ -1140,11 +1139,11 @@ def draw_curve(
shm: ShmArray,
flume: Flume,

array_key: Optional[str] = None,
array_key: str | None = None,
overlay: bool = False,
color: Optional[str] = None,
color: str | None = None,
add_label: bool = True,
pi: Optional[pg.PlotItem] = None,
pi: pg.PlotItem | None = None,
step_mode: bool = False,
is_ohlc: bool = False,
add_sticky: None | str = 'right',
Expand Down Expand Up @@ -1277,7 +1276,7 @@ def draw_ohlc(
shm: ShmArray,
flume: Flume,

array_key: Optional[str] = None,
array_key: str | None = None,
**draw_curve_kwargs,

) -> Viz:
Expand Down Expand Up @@ -1308,10 +1307,10 @@ def leaveEvent(self, ev): # noqa

def maxmin(
self,
name: Optional[str] = None,
bars_range: Optional[tuple[
name: str | None = None,
bars_range: tuple[
int, int, int, int, int, int
]] = None,
] | None = None,

) -> tuple[float, float]:
'''
Expand Down
10 changes: 6 additions & 4 deletions piker/ui/_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from __future__ import annotations
from functools import partial
from typing import (
Optional,
Callable,
TYPE_CHECKING,
)
Expand All @@ -38,7 +37,10 @@
_font_small,
_font,
)
from ._axes import YAxisLabel, XAxisLabel
from ._axes import (
YAxisLabel,
XAxisLabel,
)
from ..log import get_logger

if TYPE_CHECKING:
Expand Down Expand Up @@ -167,7 +169,7 @@ def __init__(

anchor_at: str = ('top', 'right'),
justify_text: str = 'left',
font_size: Optional[int] = None,
font_size: int | None = None,

) -> None:

Expand Down Expand Up @@ -338,7 +340,7 @@ def __init__(

self.linked = linkedsplits
self.graphics: dict[str, pg.GraphicsObject] = {}
self.xaxis_label: Optional[XAxisLabel] = None
self.xaxis_label: XAxisLabel | None = None
self.always_show_xlabel: bool = True
self.plots: list['PlotChartWidget'] = [] # type: ignore # noqa
self.active_plot = None
Expand Down
8 changes: 4 additions & 4 deletions piker/ui/_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"""
from contextlib import contextmanager as cm
from typing import Optional, Callable
from typing import Callable

import numpy as np
import pyqtgraph as pg
Expand Down Expand Up @@ -86,7 +86,7 @@ def __init__(
# line styling
color: str = 'bracket',
last_step_color: str | None = None,
fill_color: Optional[str] = None,
fill_color: str | None = None,
style: str = 'solid',

**kwargs
Expand Down Expand Up @@ -191,14 +191,14 @@ class Curve(FlowGraphic):
'''
# TODO: can we remove this?
# sub_br: Optional[Callable] = None
# sub_br: Callable | None = None

def __init__(
self,
*args,

# color: str = 'default_lightest',
# fill_color: Optional[str] = None,
# fill_color: str | None = None,
# style: str = 'solid',

**kwargs
Expand Down
5 changes: 2 additions & 3 deletions piker/ui/_dataviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
floor,
)
from typing import (
Optional,
Literal,
TYPE_CHECKING,
)
Expand Down Expand Up @@ -249,7 +248,7 @@ class Viz(msgspec.Struct): # , frozen=True):
# in some cases a viz may want to change its
# graphical "type" or, "form" when downsampling, to
# start this is only ever an interpolation line.
ds_graphics: Optional[Curve] = None
ds_graphics: Curve | None = None

is_ohlc: bool = False
render: bool = True # toggle for display loop
Expand Down Expand Up @@ -576,7 +575,7 @@ def datums_range(

def read(
self,
array_field: Optional[str] = None,
array_field: str | None = None,
index_field: str | None = None,
profiler: None | Profiler = None,

Expand Down
7 changes: 3 additions & 4 deletions piker/ui/_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from math import floor
import time
from typing import (
Optional,
Any,
TYPE_CHECKING,
)
Expand Down Expand Up @@ -205,8 +204,8 @@ class DisplayState(Struct):

globalz: None | dict[str, Any] = None

vlm_chart: Optional[ChartPlotWidget] = None
vlm_sticky: Optional[YAxisLabel] = None
vlm_chart: ChartPlotWidget | None = None
vlm_sticky: YAxisLabel | None = None
wap_in_history: bool = False


Expand Down Expand Up @@ -494,7 +493,7 @@ def graphics_update_cycle(

wap_in_history: bool = False,
trigger_all: bool = False, # flag used by prepend history updates
prepend_update_index: Optional[int] = None,
prepend_update_index: int | None = None,

) -> None:

Expand Down
5 changes: 2 additions & 3 deletions piker/ui/_editors.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from __future__ import annotations
from collections import defaultdict
from typing import (
Optional,
TYPE_CHECKING
)

Expand Down Expand Up @@ -67,7 +66,7 @@ def add(
x: float,
y: float,
color='default',
pointing: Optional[str] = None,
pointing: str | None = None,

) -> pg.ArrowItem:
'''
Expand Down Expand Up @@ -221,7 +220,7 @@ def remove_line(
line: LevelLine = None,
uuid: str = None,

) -> Optional[LevelLine]:
) -> LevelLine | None:
'''Remove a line by refernce or uuid.
If no lines or ids are provided remove all lines under the
Expand Down
Loading

0 comments on commit 020e1ae

Please sign in to comment.