Skip to content

Commit

Permalink
Add type hints
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Murray <[email protected]>
  • Loading branch information
hugovk and radarhere authored Apr 1, 2024
1 parent b6c755d commit 008b28e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ def size(self) -> tuple[int, int]:
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
Expand Down Expand Up @@ -1347,7 +1347,9 @@ def getbbox(self, *, alpha_only: bool = True) -> tuple[int, int, int, int]:
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.
Expand All @@ -1370,7 +1372,7 @@ def getcolors(self, maxcolors: int = 256) -> list[tuple[int, int]] | None:
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
Expand All @@ -1393,7 +1395,7 @@ def getdata(self, band: int | None = None) -> 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.
Expand Down

0 comments on commit 008b28e

Please sign in to comment.