mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-03 13:14:27 +03:00
Added type hints
This commit is contained in:
parent
c7a1ce16ad
commit
4da1e49036
|
@ -2643,7 +2643,7 @@ class Image:
|
||||||
resample=Resampling.NEAREST,
|
resample=Resampling.NEAREST,
|
||||||
fill=1,
|
fill=1,
|
||||||
fillcolor=None,
|
fillcolor=None,
|
||||||
):
|
) -> Image:
|
||||||
"""
|
"""
|
||||||
Transforms this image. This method creates a new image with the
|
Transforms this image. This method creates a new image with the
|
||||||
given size, and the same mode as the original, and copies data
|
given size, and the same mode as the original, and copies data
|
||||||
|
|
|
@ -14,17 +14,26 @@
|
||||||
#
|
#
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import Sequence
|
||||||
|
|
||||||
from . import Image
|
from . import Image
|
||||||
|
|
||||||
|
|
||||||
class Transform(Image.ImageTransformHandler):
|
class Transform(Image.ImageTransformHandler):
|
||||||
def __init__(self, data):
|
method: int
|
||||||
|
|
||||||
|
def __init__(self, data: Sequence[int]) -> None:
|
||||||
self.data = data
|
self.data = data
|
||||||
|
|
||||||
def getdata(self):
|
def getdata(self) -> tuple[int, Sequence[int]]:
|
||||||
return self.method, self.data
|
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
|
# can be overridden
|
||||||
method, data = self.getdata()
|
method, data = self.getdata()
|
||||||
return image.transform(size, method, data, **options)
|
return image.transform(size, method, data, **options)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user