Added type hints

This commit is contained in:
Andrew Murray 2024-01-01 19:22:01 +11:00
parent c7a1ce16ad
commit 4da1e49036
2 changed files with 13 additions and 4 deletions

View File

@ -2643,7 +2643,7 @@ class Image:
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

View File

@ -14,17 +14,26 @@
#
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)