From 77401a94fb3ff6859e80b94dae153c6f427b5a76 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Tue, 28 Feb 2023 16:02:01 -0500 Subject: [PATCH] Simplify `FlowGraphics.x_last()` logics --- piker/ui/_curve.py | 5 ++++- piker/ui/_ohlc.py | 9 +++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/piker/ui/_curve.py b/piker/ui/_curve.py index 013448f3..052a94a3 100644 --- a/piker/ui/_curve.py +++ b/piker/ui/_curve.py @@ -158,7 +158,10 @@ class FlowGraphic(pg.GraphicsObject): drawn yet, ``None``. ''' - return self._last_line.x1() if self._last_line else None + if self._last_line: + return self._last_line.x1() + + return None class Curve(FlowGraphic): diff --git a/piker/ui/_ohlc.py b/piker/ui/_ohlc.py index 344805e8..25ebb591 100644 --- a/piker/ui/_ohlc.py +++ b/piker/ui/_ohlc.py @@ -93,7 +93,7 @@ class BarItems(FlowGraphic): ''' # XXX: causes this weird jitter bug when click-drag panning # where the path curve will awkwardly flicker back and forth? - # cache_mode: int = QGraphicsItem.NoCache + cache_mode: int = QGraphicsItem.NoCache def __init__( self, @@ -113,9 +113,10 @@ class BarItems(FlowGraphic): ''' if self._last_bar_lines: close_arm_line = self._last_bar_lines[-1] - return close_arm_line.x2() if close_arm_line else None - else: - return None + if close_arm_line: + return close_arm_line.x2() + + return None # Qt docs: https://doc.qt.io/qt-5/qgraphicsitem.html#boundingRect def boundingRect(self):