From bebece467270fe02ebeb9a6c562419e6e6f9d0d6 Mon Sep 17 00:00:00 2001 From: Eric Soroos Date: Thu, 4 Jan 2018 11:58:39 +0000 Subject: [PATCH] Typing: relaxed type for MultiChannelExtrema This allows for the existence of (currently not implemented) multichannel floating point images --- src/PIL/Image.py | 2 +- src/PIL/_imaging.pyi | 2 +- src/PIL/aliases.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PIL/Image.py b/src/PIL/Image.py index ac4900933..5a9fe6438 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -1292,7 +1292,7 @@ class Image(object): self.load() if self.im.bands > 1: - extrema = [] # type: Extrema + extrema = [] for i in range(self.im.bands): ex = self.im.getband(i).getextrema() # type: MultiChannelExtrema extrema.append(ex) diff --git a/src/PIL/_imaging.pyi b/src/PIL/_imaging.pyi index 10a42549b..b2c26b029 100644 --- a/src/PIL/_imaging.pyi +++ b/src/PIL/_imaging.pyi @@ -70,7 +70,7 @@ class ImagingCore: def isblock(self) -> int: ... def getbbox(self) -> Optional[LURD]: ... def getcolors(self, maxcolors: int) -> Optional[List[Tuple[int, Color]]]: ... ################### - def getextrema(self) -> Tuple[float, float]: ... + def getextrema(self) -> SingleChannelExtrema: ... def getprojection(self) -> Tuple[List[int], List[int]]: ... def getband(self, band: int) -> ImagingCore: ... def putband(self, image: ImagingCore, band_index: int) -> None: ... diff --git a/src/PIL/aliases.py b/src/PIL/aliases.py index bdbffac33..78f5e852a 100644 --- a/src/PIL/aliases.py +++ b/src/PIL/aliases.py @@ -10,7 +10,7 @@ Matrix12 = Tuple[float, float, float, float, float, float, float, float, float, Mode = str SingleChannelExtrema = Union[Tuple[float, float], Tuple[int, int]] -MultiChannelExtrema = Tuple[int, int] +MultiChannelExtrema = SingleChannelExtrema # Note: currently only a Tuple[int,int] Extrema = Union[SingleChannelExtrema, Tuple[MultiChannelExtrema, ...]] Color = Union[int, float, Tuple[int, int], Tuple[int, int, int], Tuple[int, int, int, int]]