From 850e28a02f17ade80d89a2124932d626bfd27828 Mon Sep 17 00:00:00 2001 From: "neiljp (Neil Pilgrim)" Date: Sat, 19 Aug 2017 11:04:28 -0700 Subject: [PATCH] Type annotations: Add & use Extrema type alias. --- PIL/aliases.py | 1 + src/PIL/Image.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/PIL/aliases.py b/PIL/aliases.py index 50df1c400..7c00cad78 100644 --- a/PIL/aliases.py +++ b/PIL/aliases.py @@ -8,4 +8,5 @@ Size = XY # NOTE: All XY aliases will be interchangeable Matrix4 = Tuple[float, float, float, float] Matrix12 = Tuple[float, float, float, float, float, float, float, float, float, float, float, float] Mode = str +Extrema = Union[Tuple[Any, Any], Tuple[Tuple[Any, Any], ...]] # Any -> float? diff --git a/src/PIL/Image.py b/src/PIL/Image.py index cacedf4f5..1d0460d62 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -1283,7 +1283,7 @@ class Image(object): return self.im # could be abused def getextrema(self): - # type: () -> Tuple + # type: () -> Extrema """ Gets the the minimum and maximum pixel values for each band in the image. @@ -1359,7 +1359,7 @@ class Image(object): return [i8(c) for c in x], [i8(c) for c in y] def histogram(self, mask=None, extrema=None): - # type: (Optional[Image], Optional[Any]) -> List[int] + # type: (Optional[Image], Optional[Extrema]) -> List[int] """ Returns a histogram for the image. The histogram is returned as a list of pixel counts, one for each pixel value in the source