Skip to content

Commit

Permalink
Added strict type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Dec 25, 2023
1 parent d2dc8d3 commit 1fa83d5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from collections.abc import Callable, MutableMapping
from enum import IntEnum
from pathlib import Path
from typing_extensions import Self

try:
from defusedxml import ElementTree
Expand Down Expand Up @@ -1181,7 +1182,7 @@ def quantize(

return im

def copy(self):
def copy(self) -> Self:
"""
Copies this image. Use this method if you wish to paste things
into an image, but still retain the original.
Expand Down Expand Up @@ -2450,7 +2451,7 @@ def save(self, fp, format=None, **params):
if open_fp:
fp.close()

def seek(self, frame):
def seek(self, frame) -> Self:
"""
Seeks to the given frame in this sequence file. If you seek
beyond the end of the sequence, the method raises an
Expand Down Expand Up @@ -2537,7 +2538,7 @@ def getchannel(self, channel):

return self._new(self.im.getband(channel))

def tell(self):
def tell(self) -> int:
"""
Returns the current frame number. See :py:meth:`~PIL.Image.Image.seek`.
Expand Down
3 changes: 2 additions & 1 deletion src/PIL/ImageSequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from __future__ import annotations

from typing import Callable
from typing_extensions import Self

from . import Image

Expand Down Expand Up @@ -48,7 +49,7 @@ def __getitem__(self, ix: int) -> Image.Image:
msg = "end of sequence"
raise IndexError(msg) from e

def __iter__(self) -> Iterator:
def __iter__(self) -> Self:
return self

def __next__(self) -> Image.Image:
Expand Down

0 comments on commit 1fa83d5

Please sign in to comment.