Skip to content

Commit

Permalink
Added type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Jan 1, 2024
1 parent c7a1ce1 commit 566485a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -2643,7 +2643,7 @@ def transform(
resample=Resampling.NEAREST,
fill=1,
fillcolor=None,
):
) -> Image:
"""
Transforms this image. This method creates a new image with the
given size, and the same mode as the original, and copies data
Expand Down
10 changes: 7 additions & 3 deletions src/PIL/ImageTransform.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,21 @@
#
from __future__ import annotations

from typing import Sequence

from . import Image


class Transform(Image.ImageTransformHandler):
def __init__(self, data):
method: int

def __init__(self, data: Sequence[int]) -> None:
self.data = data

def getdata(self):
def getdata(self) -> tuple[int, Sequence[int]]:
return self.method, self.data

def transform(self, size, image, **options):
def transform(self, size: tuple[int, int], image: Image.Image, **options: dict[str, str | int | tuple[int, ...] | list[int]]) -> Image.Image:
# can be overridden
method, data = self.getdata()
return image.transform(size, method, data, **options)
Expand Down

0 comments on commit 566485a

Please sign in to comment.