summaryrefslogtreecommitdiffstats
path: root/contrib/python/Pillow/py3/PIL/ImageSequence.py
diff options
context:
space:
mode:
authorkickbutt <[email protected]>2024-01-23 23:36:43 +0300
committerkickbutt <[email protected]>2024-01-23 23:55:22 +0300
commitfe742a0b69a530f86d1ea7aa84978d673256f8b7 (patch)
treea045a5eb8dba770797e84d0b233098605396027d /contrib/python/Pillow/py3/PIL/ImageSequence.py
parentbd7d89b121ae7b9f4427766292c950fcc91c2975 (diff)
Fix separator in CUDA_ARCHITECTURES
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 c4bb6334acf..2c185027630 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.