From 64dca171b46ecde6c363d3c4b14c875bdbbc36ad Mon Sep 17 00:00:00 2001 From: Rotzbua Date: Tue, 7 Feb 2023 15:26:58 +0100 Subject: [PATCH] extents: add types * lint code --- boxes/extents.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/boxes/extents.py b/boxes/extents.py index 82a5109..b2ab4a6 100644 --- a/boxes/extents.py +++ b/boxes/extents.py @@ -1,34 +1,34 @@ class Extents: __slots__ = "xmin ymin xmax ymax".split() - def __init__(self,xmin=float('inf'),ymin=float('inf'),xmax=float('-inf'),ymax=float('-inf')) -> None: + def __init__(self, xmin: float = float('inf'), ymin: float = float('inf'), xmax: float = float('-inf'), ymax: float = float('-inf')) -> None: self.xmin = xmin self.ymin = ymin self.xmax = xmax self.ymax = ymax - def add(self,x,y): - self.xmin = min(self.xmin,x) - self.xmax = max(self.xmax,x) - self.ymin = min(self.ymin,y) - self.ymax = max(self.ymax,y) + def add(self, x: float, y: float) -> None: + self.xmin = min(self.xmin, x) + self.xmax = max(self.xmax, x) + self.ymin = min(self.ymin, y) + self.ymax = max(self.ymax, y) - def extend(self,l): - for x,y in l: - self.add(x,y) + def extend(self, l) -> None: + for x, y in l: + self.add(x, y) - def __add__(self,extent): - #todo: why can this happen? + def __add__(self, extent): + # todo: why can this happen? if extent == 0: - return Extents(self.xmin,self.ymin,self.xmax,self.ymax) + return Extents(self.xmin, self.ymin, self.xmax, self.ymax) return Extents( - min(self.xmin,extent.xmin),min(self.ymin,extent.ymin), - max(self.xmax,extent.xmax),max(self.ymax,extent.ymax) + min(self.xmin, extent.xmin), min(self.ymin, extent.ymin), + max(self.xmax, extent.xmax), max(self.ymax, extent.ymax) ) - def __radd__(self,extent): + def __radd__(self, extent): if extent == 0: - return Extents(self.xmin,self.ymin,self.xmax,self.ymax) + return Extents(self.xmin, self.ymin, self.xmax, self.ymax) return self.__add__(extent) @property