From 07c8ed8a3ad7857579b44f73732275d730abf9fa Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sat, 14 Jan 2023 16:25:02 -0500 Subject: [PATCH] Use (modern) literal type annots in view code --- piker/ui/_interaction.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/piker/ui/_interaction.py b/piker/ui/_interaction.py index bceb64ee..e19887da 100644 --- a/piker/ui/_interaction.py +++ b/piker/ui/_interaction.py @@ -21,7 +21,11 @@ Chart view box primitives from __future__ import annotations from contextlib import asynccontextmanager import time -from typing import Optional, Callable +from typing import ( + Optional, + Callable, + TYPE_CHECKING, +) import pyqtgraph as pg # from pyqtgraph.GraphicsScene import mouseEvents @@ -39,6 +43,9 @@ from .._profile import pg_profile_enabled, ms_slower_then from ._editors import SelectRect from . import _event +if TYPE_CHECKING: + from ._chart import ChartPlotWidget + log = get_logger(__name__) @@ -374,7 +381,7 @@ class ChartView(ViewBox): ) self.linked = None - self._chart: 'ChartPlotWidget' = None # noqa + self._chart: ChartPlotWidget | None = None # noqa # add our selection box annotator self.select_box = SelectRect(self) @@ -445,11 +452,11 @@ class ChartView(ViewBox): yield self @property - def chart(self) -> 'ChartPlotWidget': # type: ignore # noqa + def chart(self) -> ChartPlotWidget: # type: ignore # noqa return self._chart @chart.setter - def chart(self, chart: 'ChartPlotWidget') -> None: # type: ignore # noqa + def chart(self, chart: ChartPlotWidget) -> None: # type: ignore # noqa self._chart = chart self.select_box.chart = chart if self._maxmin is None: @@ -783,11 +790,9 @@ class ChartView(ViewBox): if yrange is None: log.warning(f'No yrange provided for {name}!?') - print(f"WTF NO YRANGE {name}") return ylow, yhigh = yrange - profiler(f'callback ._maxmin(): {yrange}') # view margins: stay within a % of the "true range"