From 008b28eb0caffb8a54fd043686cae996f0a842b6 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Sun, 31 Mar 2024 23:20:11 -0600 Subject: [PATCH] Add type hints Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com> --- src/PIL/Image.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/PIL/Image.py b/src/PIL/Image.py index ccbfe2a6f..b92c0bb43 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -524,7 +524,7 @@ class Image: def mode(self): return self._mode - def _new(self, im: Image) -> Image: + def _new(self, im: Image): new = Image() new.im = im new._mode = im.mode @@ -1347,7 +1347,9 @@ class Image: self.load() return self.im.getbbox(alpha_only) - def getcolors(self, maxcolors: int = 256) -> list[tuple[int, int]] | None: + def getcolors( + self, maxcolors: int = 256 + ) -> list[tuple[int, int | tuple[int, ...]]] | None: """ Returns a list of colors used in this image. @@ -1370,7 +1372,7 @@ class Image: return out return self.im.getcolors(maxcolors) - def getdata(self, band: int | None = None) -> Image: + def getdata(self, band: int | None = None): """ Returns the contents of this image as a sequence object containing pixel values. The sequence object is flattened, so @@ -1393,7 +1395,7 @@ class Image: return self.im.getband(band) return self.im # could be abused - def getextrema(self) -> tuple[float, float] | tuple[tuple[float, float], ...]: + def getextrema(self) -> tuple[float, float] | tuple[tuple[int, int], ...]: """ Gets the minimum and maximum pixel values for each band in the image.