aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/Pillow/py3/PIL/ImageSequence.py
diff options
context:
space:
mode:
authorAlexSm <alex@ydb.tech>2024-01-26 16:00:50 +0100
committerGitHub <noreply@github.com>2024-01-26 16:00:50 +0100
commit7ebcfd058d924bcc8c23da70e034f7415687885c (patch)
treee4f00d163c77528c1855f2d7af54a8be83fc1ccb /contrib/python/Pillow/py3/PIL/ImageSequence.py
parent64ca2dcd06312b9eef624054ceb5f787e11be79a (diff)
parent6d79e7793c2c462134f4b4a7d911abc7b9b0766f (diff)
downloadydb-7ebcfd058d924bcc8c23da70e034f7415687885c.tar.gz
Merge pull request #1260 from ydb-platform/mergelibs10
mergelibs10
Diffstat (limited to 'contrib/python/Pillow/py3/PIL/ImageSequence.py')
-rw-r--r--contrib/python/Pillow/py3/PIL/ImageSequence.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/contrib/python/Pillow/py3/PIL/ImageSequence.py b/contrib/python/Pillow/py3/PIL/ImageSequence.py
index c4bb6334ac..2c18502763 100644
--- a/contrib/python/Pillow/py3/PIL/ImageSequence.py
+++ b/contrib/python/Pillow/py3/PIL/ImageSequence.py
@@ -14,6 +14,11 @@
#
##
+from __future__ import annotations
+
+from typing import Callable
+
+from . import Image
class Iterator:
@@ -28,33 +33,38 @@ class Iterator:
:param im: An image object.
"""
- def __init__(self, im):
+ def __init__(self, im: Image.Image):
if not hasattr(im, "seek"):
msg = "im must have seek method"
raise AttributeError(msg)
self.im = im
self.position = getattr(self.im, "_min_frame", 0)
- def __getitem__(self, ix):
+ def __getitem__(self, ix: int) -> Image.Image:
try:
self.im.seek(ix)
return self.im
except EOFError as e:
- raise IndexError from e # end of sequence
+ msg = "end of sequence"
+ raise IndexError(msg) from e
- def __iter__(self):
+ def __iter__(self) -> Iterator:
return self
- def __next__(self):
+ def __next__(self) -> Image.Image:
try:
self.im.seek(self.position)
self.position += 1
return self.im
except EOFError as e:
- raise StopIteration from e
+ msg = "end of sequence"
+ raise StopIteration(msg) from e
-def all_frames(im, func=None):
+def all_frames(
+ im: Image.Image | list[Image.Image],
+ func: Callable[[Image.Image], Image.Image] | None = None,
+) -> list[Image.Image]:
"""
Applies a given function to all frames in an image or a list of images.
The frames are returned as a list of separate images.