Skip to content

Commit 9ec0df9

Browse files
committed
Typing
1 parent 83f8477 commit 9ec0df9

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

src/silx/gui/plot/items/_roi_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,15 +603,15 @@ def _updated(self, event=None, checkVisibility=True):
603603
if event == items.ItemChangedType.NAME and self.__text is None:
604604
self._updated(items.ItemChangedType.TEXT, checkVisibility)
605605

606-
def _updatedStyle(self, event, style):
606+
def _updatedStyle(self, event, style: items.CurveStyle):
607607
"""Called when the current displayed style of the ROI was changed.
608608
609609
:param event: The event responsible of the change of the style
610610
:param items.CurveStyle style: The current style
611611
"""
612612
pass
613613

614-
def getCurrentStyle(self):
614+
def getCurrentStyle(self) -> items.CurveStyle:
615615
"""Returns the current curve style.
616616
617617
Curve style depends on curve highlighting

src/silx/gui/plot/items/roi.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def _updated(self, event=None, checkVisibility=True):
237237
self._updateItemProperty(event, self, self.__shape)
238238
super(LineROI, self)._updated(event, checkVisibility)
239239

240-
def _updatedStyle(self, event, style):
240+
def _updatedStyle(self, event, style: items.CurveStyle):
241241
super(LineROI, self)._updatedStyle(event, style)
242242
self.__shape.setColor(style.getColor())
243243
self.__shape.setLineStyle(style.getLineStyle())
@@ -251,7 +251,7 @@ def setFirstShapePoints(self, points):
251251
def _updateText(self, text):
252252
self._handleLabel.setText(text)
253253

254-
def setEndPoints(self, startPoint, endPoint):
254+
def setEndPoints(self, startPoint: numpy.ndarray, endPoint: numpy.ndarray):
255255
"""Set this line location using the ending points
256256
257257
:param numpy.ndarray startPoint: Staring bounding point of the line
@@ -260,7 +260,7 @@ def setEndPoints(self, startPoint, endPoint):
260260
if not numpy.array_equal((startPoint, endPoint), self.getEndPoints()):
261261
self.__updateEndPoints(startPoint, endPoint)
262262

263-
def __updateEndPoints(self, startPoint, endPoint):
263+
def __updateEndPoints(self, startPoint: numpy.ndarray, endPoint: numpy.ndarray):
264264
"""Update marker and shape to match given end points
265265
266266
:param numpy.ndarray startPoint: Staring bounding point of the line

src/silx/gui/plot/tools/RulerToolButton.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import logging
3434
import numpy
3535
import weakref
36+
import typing
3637

3738
from silx.gui import icons
3839

@@ -48,13 +49,22 @@
4849
class _RulerROI(LineROI):
4950
def __init__(self, parent=None):
5051
super().__init__(parent)
51-
self._formatFunction = None
52+
self._formatFunction: typing.Optional[
53+
typing.Callable[
54+
[numpy.ndarray, numpy.ndarray], str
55+
]
56+
] = None
5257

53-
def registerFormatFunction(self, fct):
54-
"""fct is expected to be a function taking (startPoint, endPoint) as parameter"""
58+
def registerFormatFunction(
59+
self,
60+
fct: typing.Callable[
61+
[numpy.ndarray, numpy.ndarray], str
62+
],
63+
):
64+
"""Register a function for the formatting of the label"""
5565
self._formatFunction = fct
5666

57-
def setEndPoints(self, startPoint, endPoint):
67+
def setEndPoints(self, startPoint: numpy.ndarray, endPoint: numpy.ndarray):
5868
super().setEndPoints(startPoint=startPoint, endPoint=endPoint)
5969
if self._formatFunction is not None:
6070
ruler_text = self._formatFunction(
@@ -151,7 +161,7 @@ def _registerCurrentROI(self, currentRoi):
151161
currentRoi.registerFormatFunction(self.buildDistanceText)
152162
self.__lastRoiCreated = weakref.ref(currentRoi)
153163

154-
def buildDistanceText(self, startPoint, endPoint):
164+
def buildDistanceText(self, startPoint: numpy.ndarray, endPoint: numpy.ndarray) -> str:
155165
"""
156166
Define the text to be displayed by the ruler.
157167

0 commit comments

Comments
 (0)