From 64ee793ebbfa0773b3df6f2d0406fd8e2c0be00e Mon Sep 17 00:00:00 2001 From: ow0x <24418520+ow0x@users.noreply.github.com> Date: Thu, 28 Jul 2022 11:02:04 +0000 Subject: [PATCH 01/10] update deprecated `PIL.Image` constants --- stubs/Pillow/PIL/Image.pyi | 73 ++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/stubs/Pillow/PIL/Image.pyi b/stubs/Pillow/PIL/Image.pyi index d892d2187031..d8dec43c3d6f 100644 --- a/stubs/Pillow/PIL/Image.pyi +++ b/stubs/Pillow/PIL/Image.pyi @@ -1,5 +1,6 @@ from _typeshed import Self, SupportsRead, SupportsWrite from collections.abc import Callable, Iterable, Iterator, MutableMapping, Sequence +from enum import IntEnum from pathlib import Path from typing import Any, ClassVar, Protocol, SupportsBytes, Union from typing_extensions import Literal, TypeAlias @@ -15,7 +16,6 @@ from .ImageFilter import Filter from .ImagePalette import ImagePalette _Mode: TypeAlias = str -_Resample: TypeAlias = Literal[0, 1, 2, 3, 4, 5] _Size: TypeAlias = tuple[int, int] _Box: TypeAlias = tuple[int, int, int, int] @@ -42,41 +42,44 @@ MAX_IMAGE_PIXELS: int NONE: Literal[0] -FLIP_LEFT_RIGHT: Literal[0] -FLIP_TOP_BOTTOM: Literal[1] -ROTATE_90: Literal[2] -ROTATE_180: Literal[3] -ROTATE_270: Literal[4] -TRANSPOSE: Literal[5] -TRANSVERSE: Literal[6] +class Transpose(IntEnum): + FLIP_TOP_BOTTOM: Literal[0] + ROTATE_90: Literal[1] + ROTATE_180: Literal[2] + ROTATE_270: Literal[3] + TRANSPOSE: Literal[4] + TRANSVERSE: Literal[5] -AFFINE: Literal[0] -EXTENT: Literal[1] -PERSPECTIVE: Literal[2] -QUAD: Literal[3] -MESH: Literal[4] +class Transform(IntEnum): + AFFINE: Literal[0] + EXTENT: Literal[1] + PERSPECTIVE: Literal[2] + QUAD: Literal[3] + MESH: Literal[4] -NEAREST: Literal[0] -BOX: Literal[4] -BILINEAR: Literal[2] -LINEAR: Literal[2] -HAMMING: Literal[5] -BICUBIC: Literal[3] -CUBIC: Literal[3] -LANCZOS: Literal[1] -ANTIALIAS: Literal[1] +class Resampling(IntEnum): + NEAREST: Literal[0] + LANCZOS: Literal[1] + BILINEAR: Literal[2] + BICUBIC: Literal[3] + BOX: Literal[4] + HAMMING: Literal[5] -ORDERED: Literal[1] -RASTERIZE: Literal[2] -FLOYDSTEINBERG: Literal[3] +class Dither(IntEnum): + NONE: Literal[0] + ORDERED: Literal[1] + RASTERIZE: Literal[2] + FLOYDSTEINBERG: Literal[3] -WEB: Literal[0] -ADAPTIVE: Literal[1] +class Palette(IntEnum): + WEB: Literal[0] + ADAPTIVE: Literal[1] -MEDIANCUT: Literal[0] -MAXCOVERAGE: Literal[1] -FASTOCTREE: Literal[2] -LIBIMAGEQUANT: Literal[3] +class Quantize(IntEnum): + MEDIANCUT: Literal[0] + MAXCOVERAGE: Literal[1] + FASTOCTREE: Literal[2] + LIBIMAGEQUANT: Literal[3] ID: list[str] OPEN: dict[str, Any] @@ -176,7 +179,7 @@ class Image: def resize( self, size: tuple[int, int], - resample: _Resample | None = ..., + resample: Resampling | None = ..., box: tuple[float, float, float, float] | None = ..., reducing_gap: float | None = ..., ) -> Image: ... @@ -184,7 +187,7 @@ class Image: def rotate( self, angle: float, - resample: _Resample = ..., + resample: Resampling = ..., expand: bool = ..., center: tuple[float, float] | None = ..., translate: tuple[float, float] | None = ..., @@ -204,13 +207,13 @@ class Image: def split(self) -> tuple[Image, ...]: ... def getchannel(self, channel: int | str) -> Image: ... def tell(self) -> int: ... - def thumbnail(self, size: tuple[int, int], resample: _Resample = ..., reducing_gap: float = ...) -> None: ... + def thumbnail(self, size: tuple[int, int], resample: Resampling = ..., reducing_gap: float = ...) -> None: ... def transform( self, size: _Size, method: Literal[0, 1, 2, 3, 4], data=..., - resample: _Resample = ..., + resample: Resampling = ..., fill: int = ..., fillcolor: _Color | int | None = ..., ) -> Image: ... From 36344f2743421bacc9ab5d53787575ca249ed093 Mon Sep 17 00:00:00 2001 From: ow0x <24418520+ow0x@users.noreply.github.com> Date: Thu, 28 Jul 2022 11:32:38 +0000 Subject: [PATCH 02/10] fix CI --- stubs/Pillow/PIL/ImageOps.pyi | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/stubs/Pillow/PIL/ImageOps.pyi b/stubs/Pillow/PIL/ImageOps.pyi index 77b9662035de..0bc6e663c8f4 100644 --- a/stubs/Pillow/PIL/ImageOps.pyi +++ b/stubs/Pillow/PIL/ImageOps.pyi @@ -2,7 +2,7 @@ from collections.abc import Iterable from typing import Any, Protocol, Union from typing_extensions import TypeAlias -from .Image import Image, _Resample, _Size +from .Image import Image, Resampling, _Size from .ImageColor import _Ink _Border: TypeAlias = Union[int, tuple[int, int], tuple[int, int, int, int]] @@ -22,16 +22,16 @@ def colorize( whitepoint: int = ..., midpoint: int = ..., ) -> Image: ... -def contain(image: Image, size: _Size, method: _Resample = ...) -> Image: ... +def contain(image: Image, size: _Size, method: Resampling = ...) -> Image: ... def pad( - image: Image, size: _Size, method: _Resample = ..., color: Any | None = ..., centering: Iterable[float] = ... + image: Image, size: _Size, method: Resampling = ..., color: Any | None = ..., centering: Iterable[float] = ... ) -> Image: ... def crop(image: Image, border: _Border = ...) -> Image: ... -def scale(image: Image, factor: float, resample: _Resample = ...) -> Image: ... -def deform(image: Image, deformer: _Deformer, resample: _Resample = ...) -> Image: ... +def scale(image: Image, factor: float, resample: Resampling = ...) -> Image: ... +def deform(image: Image, deformer: _Deformer, resample: Resampling = ...) -> Image: ... def equalize(image: Image, mask: Any | None = ...) -> Image: ... def expand(image: Image, border: _Border = ..., fill: _Ink = ...) -> Image: ... -def fit(image: Image, size: _Size, method: _Resample = ..., bleed: float = ..., centering: Iterable[float] = ...) -> Image: ... +def fit(image: Image, size: _Size, method: Resampling = ..., bleed: float = ..., centering: Iterable[float] = ...) -> Image: ... def flip(image: Image) -> Image: ... def grayscale(image: Image) -> Image: ... def invert(image: Image) -> Image: ... From 32bc226948d2b1232011ffbab1cca4d47f47720a Mon Sep 17 00:00:00 2001 From: ow0x <24418520+ow0x@users.noreply.github.com> Date: Thu, 28 Jul 2022 11:50:27 +0000 Subject: [PATCH 03/10] attempt to fix stubtest CI --- stubs/Pillow/PIL/Image.pyi | 89 ++++++++++++++++++++++++++------------ 1 file changed, 62 insertions(+), 27 deletions(-) diff --git a/stubs/Pillow/PIL/Image.pyi b/stubs/Pillow/PIL/Image.pyi index d8dec43c3d6f..0a5f9e43a848 100644 --- a/stubs/Pillow/PIL/Image.pyi +++ b/stubs/Pillow/PIL/Image.pyi @@ -42,44 +42,79 @@ MAX_IMAGE_PIXELS: int NONE: Literal[0] +FLIP_TOP_BOTTOM: Literal[1] +ROTATE_90: Literal[2] +ROTATE_180: Literal[3] +ROTATE_270: Literal[4] +TRANSPOSE: Literal[5] +TRANSVERSE: Literal[6] + +AFFINE: Literal[0] +EXTENT: Literal[1] +PERSPECTIVE: Literal[2] +QUAD: Literal[3] +MESH: Literal[4] + +NEAREST: Literal[0] +BOX: Literal[4] +BILINEAR: Literal[2] +LINEAR: Literal[2] +HAMMING: Literal[5] +BICUBIC: Literal[3] +CUBIC: Literal[3] +LANCZOS: Literal[1] +ANTIALIAS: Literal[1] + +ORDERED: Literal[1] +RASTERIZE: Literal[2] +FLOYDSTEINBERG: Literal[3] + +WEB: Literal[0] +ADAPTIVE: Literal[1] + +MEDIANCUT: Literal[0] +MAXCOVERAGE: Literal[1] +FASTOCTREE: Literal[2] +LIBIMAGEQUANT: Literal[3] + class Transpose(IntEnum): - FLIP_TOP_BOTTOM: Literal[0] - ROTATE_90: Literal[1] - ROTATE_180: Literal[2] - ROTATE_270: Literal[3] - TRANSPOSE: Literal[4] - TRANSVERSE: Literal[5] + FLIP_TOP_BOTTOM: int + ROTATE_90: int + ROTATE_180: int + ROTATE_270: int + TRANSPOSE: int + TRANSVERSE: int class Transform(IntEnum): - AFFINE: Literal[0] - EXTENT: Literal[1] - PERSPECTIVE: Literal[2] - QUAD: Literal[3] - MESH: Literal[4] + AFFINE: int + EXTENT: int + PERSPECTIVE: int + QUAD: int + MESH: int class Resampling(IntEnum): - NEAREST: Literal[0] - LANCZOS: Literal[1] - BILINEAR: Literal[2] - BICUBIC: Literal[3] - BOX: Literal[4] - HAMMING: Literal[5] + NEAREST: int + LANCZOS: int + BILINEAR: int + BICUBIC: int + BOX: int + HAMMING: int class Dither(IntEnum): - NONE: Literal[0] - ORDERED: Literal[1] - RASTERIZE: Literal[2] - FLOYDSTEINBERG: Literal[3] + NONE: int + ORDERED: int + RASTERIZE: int + FLOYDSTEINBERG: int class Palette(IntEnum): - WEB: Literal[0] - ADAPTIVE: Literal[1] + WEB: int + ADAPTIVE: int class Quantize(IntEnum): - MEDIANCUT: Literal[0] - MAXCOVERAGE: Literal[1] - FASTOCTREE: Literal[2] - LIBIMAGEQUANT: Literal[3] + MEDIANCUT: int + MAXCOVERAGE: int + FASTOCTREE: int + LIBIMAGEQUANT: int ID: list[str] OPEN: dict[str, Any] From 7c6873326a644e6ac1f802b299776fb848d2e0d0 Mon Sep 17 00:00:00 2001 From: ow0x <24418520+ow0x@users.noreply.github.com> Date: Thu, 28 Jul 2022 12:11:46 +0000 Subject: [PATCH 04/10] attempt@2 to fix stubtest CI --- stubs/Pillow/PIL/Image.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stubs/Pillow/PIL/Image.pyi b/stubs/Pillow/PIL/Image.pyi index 0a5f9e43a848..21f0ef2e491c 100644 --- a/stubs/Pillow/PIL/Image.pyi +++ b/stubs/Pillow/PIL/Image.pyi @@ -42,6 +42,7 @@ MAX_IMAGE_PIXELS: int NONE: Literal[0] +FLIP_LEFT_RIGHT: Literal[0] FLIP_TOP_BOTTOM: Literal[1] ROTATE_90: Literal[2] ROTATE_180: Literal[3] @@ -175,7 +176,7 @@ class Image: mode: _Mode | None = ..., matrix: _ConversionMatrix | None = ..., dither: int | None = ..., - palette: Literal[0, 1] = ..., + palette: Literal[Palette.WEB] = ..., colors: int = ..., ) -> Image: ... def quantize( From 491ad17993c3aed90f4b7c1853ef6256ddbb735e Mon Sep 17 00:00:00 2001 From: ow0x <24418520+ow0x@users.noreply.github.com> Date: Thu, 28 Jul 2022 19:23:35 +0000 Subject: [PATCH 05/10] allow both constants and enum --- stubs/Pillow/PIL/Image.pyi | 10 ++++++---- stubs/Pillow/PIL/ImageOps.pyi | 14 ++++++++------ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/stubs/Pillow/PIL/Image.pyi b/stubs/Pillow/PIL/Image.pyi index 21f0ef2e491c..45fbf1893898 100644 --- a/stubs/Pillow/PIL/Image.pyi +++ b/stubs/Pillow/PIL/Image.pyi @@ -16,6 +16,7 @@ from .ImageFilter import Filter from .ImagePalette import ImagePalette _Mode: TypeAlias = str +_Resample: TypeAlias = Literal[0, 1, 2, 3, 4, 5] _Size: TypeAlias = tuple[int, int] _Box: TypeAlias = tuple[int, int, int, int] @@ -79,6 +80,7 @@ FASTOCTREE: Literal[2] LIBIMAGEQUANT: Literal[3] class Transpose(IntEnum): + FLIP_LEFT_RIGHT: int FLIP_TOP_BOTTOM: int ROTATE_90: int ROTATE_180: int @@ -215,7 +217,7 @@ class Image: def resize( self, size: tuple[int, int], - resample: Resampling | None = ..., + resample: Resampling | _Resample | None = ..., box: tuple[float, float, float, float] | None = ..., reducing_gap: float | None = ..., ) -> Image: ... @@ -223,7 +225,7 @@ class Image: def rotate( self, angle: float, - resample: Resampling = ..., + resample: Resampling | _Resample = ..., expand: bool = ..., center: tuple[float, float] | None = ..., translate: tuple[float, float] | None = ..., @@ -243,13 +245,13 @@ class Image: def split(self) -> tuple[Image, ...]: ... def getchannel(self, channel: int | str) -> Image: ... def tell(self) -> int: ... - def thumbnail(self, size: tuple[int, int], resample: Resampling = ..., reducing_gap: float = ...) -> None: ... + def thumbnail(self, size: tuple[int, int], resample: Resampling | _Resample = ..., reducing_gap: float = ...) -> None: ... def transform( self, size: _Size, method: Literal[0, 1, 2, 3, 4], data=..., - resample: Resampling = ..., + resample: Resampling | _Resample = ..., fill: int = ..., fillcolor: _Color | int | None = ..., ) -> Image: ... diff --git a/stubs/Pillow/PIL/ImageOps.pyi b/stubs/Pillow/PIL/ImageOps.pyi index 0bc6e663c8f4..999879c595cf 100644 --- a/stubs/Pillow/PIL/ImageOps.pyi +++ b/stubs/Pillow/PIL/ImageOps.pyi @@ -2,7 +2,7 @@ from collections.abc import Iterable from typing import Any, Protocol, Union from typing_extensions import TypeAlias -from .Image import Image, Resampling, _Size +from .Image import Image, Resampling, _Resample, _Size from .ImageColor import _Ink _Border: TypeAlias = Union[int, tuple[int, int], tuple[int, int, int, int]] @@ -22,16 +22,18 @@ def colorize( whitepoint: int = ..., midpoint: int = ..., ) -> Image: ... -def contain(image: Image, size: _Size, method: Resampling = ...) -> Image: ... +def contain(image: Image, size: _Size, method: Resampling | _Resample = ...) -> Image: ... def pad( - image: Image, size: _Size, method: Resampling = ..., color: Any | None = ..., centering: Iterable[float] = ... + image: Image, size: _Size, method: Resampling | _Resample = ..., color: Any | None = ..., centering: Iterable[float] = ... ) -> Image: ... def crop(image: Image, border: _Border = ...) -> Image: ... -def scale(image: Image, factor: float, resample: Resampling = ...) -> Image: ... -def deform(image: Image, deformer: _Deformer, resample: Resampling = ...) -> Image: ... +def scale(image: Image, factor: float, resample: Resampling | _Resample = ...) -> Image: ... +def deform(image: Image, deformer: _Deformer, resample: Resampling | _Resample = ...) -> Image: ... def equalize(image: Image, mask: Any | None = ...) -> Image: ... def expand(image: Image, border: _Border = ..., fill: _Ink = ...) -> Image: ... -def fit(image: Image, size: _Size, method: Resampling = ..., bleed: float = ..., centering: Iterable[float] = ...) -> Image: ... +def fit( + image: Image, size: _Size, method: Resampling | _Resample = ..., bleed: float = ..., centering: Iterable[float] = ... +) -> Image: ... def flip(image: Image) -> Image: ... def grayscale(image: Image) -> Image: ... def invert(image: Image) -> Image: ... From d8b82a1abccb416386190a8d94d53180cf4c3906 Mon Sep 17 00:00:00 2001 From: ow0x <24418520+ow0x@users.noreply.github.com> Date: Thu, 28 Jul 2022 19:55:46 +0000 Subject: [PATCH 06/10] attempt fix for mypy_primer --- stubs/Pillow/PIL/Image.pyi | 8 ++++---- stubs/Pillow/PIL/ImageOps.pyi | 14 ++++++-------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/stubs/Pillow/PIL/Image.pyi b/stubs/Pillow/PIL/Image.pyi index 45fbf1893898..6b8a521fcfde 100644 --- a/stubs/Pillow/PIL/Image.pyi +++ b/stubs/Pillow/PIL/Image.pyi @@ -217,7 +217,7 @@ class Image: def resize( self, size: tuple[int, int], - resample: Resampling | _Resample | None = ..., + resample: _Resample | None = ..., box: tuple[float, float, float, float] | None = ..., reducing_gap: float | None = ..., ) -> Image: ... @@ -225,7 +225,7 @@ class Image: def rotate( self, angle: float, - resample: Resampling | _Resample = ..., + resample: _Resample = ..., expand: bool = ..., center: tuple[float, float] | None = ..., translate: tuple[float, float] | None = ..., @@ -245,13 +245,13 @@ class Image: def split(self) -> tuple[Image, ...]: ... def getchannel(self, channel: int | str) -> Image: ... def tell(self) -> int: ... - def thumbnail(self, size: tuple[int, int], resample: Resampling | _Resample = ..., reducing_gap: float = ...) -> None: ... + def thumbnail(self, size: tuple[int, int], resample: _Resample = ..., reducing_gap: float = ...) -> None: ... def transform( self, size: _Size, method: Literal[0, 1, 2, 3, 4], data=..., - resample: Resampling | _Resample = ..., + resample: _Resample = ..., fill: int = ..., fillcolor: _Color | int | None = ..., ) -> Image: ... diff --git a/stubs/Pillow/PIL/ImageOps.pyi b/stubs/Pillow/PIL/ImageOps.pyi index 999879c595cf..77b9662035de 100644 --- a/stubs/Pillow/PIL/ImageOps.pyi +++ b/stubs/Pillow/PIL/ImageOps.pyi @@ -2,7 +2,7 @@ from collections.abc import Iterable from typing import Any, Protocol, Union from typing_extensions import TypeAlias -from .Image import Image, Resampling, _Resample, _Size +from .Image import Image, _Resample, _Size from .ImageColor import _Ink _Border: TypeAlias = Union[int, tuple[int, int], tuple[int, int, int, int]] @@ -22,18 +22,16 @@ def colorize( whitepoint: int = ..., midpoint: int = ..., ) -> Image: ... -def contain(image: Image, size: _Size, method: Resampling | _Resample = ...) -> Image: ... +def contain(image: Image, size: _Size, method: _Resample = ...) -> Image: ... def pad( - image: Image, size: _Size, method: Resampling | _Resample = ..., color: Any | None = ..., centering: Iterable[float] = ... + image: Image, size: _Size, method: _Resample = ..., color: Any | None = ..., centering: Iterable[float] = ... ) -> Image: ... def crop(image: Image, border: _Border = ...) -> Image: ... -def scale(image: Image, factor: float, resample: Resampling | _Resample = ...) -> Image: ... -def deform(image: Image, deformer: _Deformer, resample: Resampling | _Resample = ...) -> Image: ... +def scale(image: Image, factor: float, resample: _Resample = ...) -> Image: ... +def deform(image: Image, deformer: _Deformer, resample: _Resample = ...) -> Image: ... def equalize(image: Image, mask: Any | None = ...) -> Image: ... def expand(image: Image, border: _Border = ..., fill: _Ink = ...) -> Image: ... -def fit( - image: Image, size: _Size, method: Resampling | _Resample = ..., bleed: float = ..., centering: Iterable[float] = ... -) -> Image: ... +def fit(image: Image, size: _Size, method: _Resample = ..., bleed: float = ..., centering: Iterable[float] = ...) -> Image: ... def flip(image: Image) -> Image: ... def grayscale(image: Image) -> Image: ... def invert(image: Image) -> Image: ... From 784db0f037c9b811405aa54bb4064ba1ef8a558f Mon Sep 17 00:00:00 2001 From: ow0x <24418520+ow0x@users.noreply.github.com> Date: Thu, 28 Jul 2022 20:18:27 +0000 Subject: [PATCH 07/10] attempt fix for stubtest CI --- stubs/Pillow/PIL/Image.pyi | 64 +++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/stubs/Pillow/PIL/Image.pyi b/stubs/Pillow/PIL/Image.pyi index 6b8a521fcfde..2545617fcf91 100644 --- a/stubs/Pillow/PIL/Image.pyi +++ b/stubs/Pillow/PIL/Image.pyi @@ -80,44 +80,44 @@ FASTOCTREE: Literal[2] LIBIMAGEQUANT: Literal[3] class Transpose(IntEnum): - FLIP_LEFT_RIGHT: int - FLIP_TOP_BOTTOM: int - ROTATE_90: int - ROTATE_180: int - ROTATE_270: int - TRANSPOSE: int - TRANSVERSE: int + FLIP_LEFT_RIGHT: Literal[0] + FLIP_TOP_BOTTOM: Literal[1] + ROTATE_90: Literal[2] + ROTATE_180: Literal[3] + ROTATE_270: Literal[4] + TRANSPOSE: Literal[5] + TRANSVERSE: Literal[6] class Transform(IntEnum): - AFFINE: int - EXTENT: int - PERSPECTIVE: int - QUAD: int - MESH: int + AFFINE: Literal[0] + EXTENT: Literal[1] + PERSPECTIVE: Literal[2] + QUAD: Literal[3] + MESH: Literal[4] class Resampling(IntEnum): - NEAREST: int - LANCZOS: int - BILINEAR: int - BICUBIC: int - BOX: int - HAMMING: int + NEAREST: Literal[0] + LANCZOS: Literal[1] + BILINEAR: Literal[2] + BICUBIC: Literal[3] + BOX: Literal[4] + HAMMING: Literal[5] class Dither(IntEnum): - NONE: int - ORDERED: int - RASTERIZE: int - FLOYDSTEINBERG: int + NONE: Literal[0] + ORDERED: Literal[1] + RASTERIZE: Literal[2] + FLOYDSTEINBERG: Literal[3] class Palette(IntEnum): - WEB: int - ADAPTIVE: int + WEB: Literal[0] + ADAPTIVE: Literal[1] class Quantize(IntEnum): - MEDIANCUT: int - MAXCOVERAGE: int - FASTOCTREE: int - LIBIMAGEQUANT: int + MEDIANCUT: Literal[0] + MAXCOVERAGE: Literal[1] + FASTOCTREE: Literal[2] + LIBIMAGEQUANT: Literal[3] ID: list[str] OPEN: dict[str, Any] @@ -217,7 +217,7 @@ class Image: def resize( self, size: tuple[int, int], - resample: _Resample | None = ..., + resample: Resampling | _Resample | None = ..., box: tuple[float, float, float, float] | None = ..., reducing_gap: float | None = ..., ) -> Image: ... @@ -225,7 +225,7 @@ class Image: def rotate( self, angle: float, - resample: _Resample = ..., + resample: Resampling | _Resample = ..., expand: bool = ..., center: tuple[float, float] | None = ..., translate: tuple[float, float] | None = ..., @@ -245,13 +245,13 @@ class Image: def split(self) -> tuple[Image, ...]: ... def getchannel(self, channel: int | str) -> Image: ... def tell(self) -> int: ... - def thumbnail(self, size: tuple[int, int], resample: _Resample = ..., reducing_gap: float = ...) -> None: ... + def thumbnail(self, size: tuple[int, int], resample: Resampling | _Resample = ..., reducing_gap: float = ...) -> None: ... def transform( self, size: _Size, method: Literal[0, 1, 2, 3, 4], data=..., - resample: _Resample = ..., + resample: Resampling | _Resample = ..., fill: int = ..., fillcolor: _Color | int | None = ..., ) -> Image: ... From b80e02a20dd10191001d71415d5952bf1a68d4ab Mon Sep 17 00:00:00 2001 From: ow0x <24418520+ow0x@users.noreply.github.com> Date: Thu, 28 Jul 2022 20:44:48 +0000 Subject: [PATCH 08/10] fix: stubtest CI --- stubs/Pillow/PIL/ImageOps.pyi | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/stubs/Pillow/PIL/ImageOps.pyi b/stubs/Pillow/PIL/ImageOps.pyi index 77b9662035de..999879c595cf 100644 --- a/stubs/Pillow/PIL/ImageOps.pyi +++ b/stubs/Pillow/PIL/ImageOps.pyi @@ -2,7 +2,7 @@ from collections.abc import Iterable from typing import Any, Protocol, Union from typing_extensions import TypeAlias -from .Image import Image, _Resample, _Size +from .Image import Image, Resampling, _Resample, _Size from .ImageColor import _Ink _Border: TypeAlias = Union[int, tuple[int, int], tuple[int, int, int, int]] @@ -22,16 +22,18 @@ def colorize( whitepoint: int = ..., midpoint: int = ..., ) -> Image: ... -def contain(image: Image, size: _Size, method: _Resample = ...) -> Image: ... +def contain(image: Image, size: _Size, method: Resampling | _Resample = ...) -> Image: ... def pad( - image: Image, size: _Size, method: _Resample = ..., color: Any | None = ..., centering: Iterable[float] = ... + image: Image, size: _Size, method: Resampling | _Resample = ..., color: Any | None = ..., centering: Iterable[float] = ... ) -> Image: ... def crop(image: Image, border: _Border = ...) -> Image: ... -def scale(image: Image, factor: float, resample: _Resample = ...) -> Image: ... -def deform(image: Image, deformer: _Deformer, resample: _Resample = ...) -> Image: ... +def scale(image: Image, factor: float, resample: Resampling | _Resample = ...) -> Image: ... +def deform(image: Image, deformer: _Deformer, resample: Resampling | _Resample = ...) -> Image: ... def equalize(image: Image, mask: Any | None = ...) -> Image: ... def expand(image: Image, border: _Border = ..., fill: _Ink = ...) -> Image: ... -def fit(image: Image, size: _Size, method: _Resample = ..., bleed: float = ..., centering: Iterable[float] = ...) -> Image: ... +def fit( + image: Image, size: _Size, method: Resampling | _Resample = ..., bleed: float = ..., centering: Iterable[float] = ... +) -> Image: ... def flip(image: Image) -> Image: ... def grayscale(image: Image) -> Image: ... def invert(image: Image) -> Image: ... From 896cb75c363ab6a8a953dcb0bc54740722ad6b8a Mon Sep 17 00:00:00 2001 From: ow0x <24418520+ow0x@users.noreply.github.com> Date: Fri, 29 Jul 2022 02:32:27 +0530 Subject: [PATCH 09/10] Update stubs/Pillow/PIL/Image.pyi Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com> --- stubs/Pillow/PIL/Image.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/Pillow/PIL/Image.pyi b/stubs/Pillow/PIL/Image.pyi index 2545617fcf91..8fc6682299fa 100644 --- a/stubs/Pillow/PIL/Image.pyi +++ b/stubs/Pillow/PIL/Image.pyi @@ -249,7 +249,7 @@ class Image: def transform( self, size: _Size, - method: Literal[0, 1, 2, 3, 4], + method: Transform | Literal[0, 1, 2, 3, 4], data=..., resample: Resampling | _Resample = ..., fill: int = ..., From f86e319a56682e6a3cce661bd48e554b20c5fe48 Mon Sep 17 00:00:00 2001 From: ow0x <24418520+ow0x@users.noreply.github.com> Date: Thu, 28 Jul 2022 21:10:21 +0000 Subject: [PATCH 10/10] address review suggestion --- stubs/Pillow/PIL/Image.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/Pillow/PIL/Image.pyi b/stubs/Pillow/PIL/Image.pyi index 8fc6682299fa..ee5a4c3e7215 100644 --- a/stubs/Pillow/PIL/Image.pyi +++ b/stubs/Pillow/PIL/Image.pyi @@ -255,7 +255,7 @@ class Image: fill: int = ..., fillcolor: _Color | int | None = ..., ) -> Image: ... - def transpose(self, method: Literal[0, 1, 2, 3, 4, 5, 6]) -> Image: ... + def transpose(self, method: Transpose | Literal[0, 1, 2, 3, 4, 5, 6]) -> Image: ... def effect_spread(self, distance: int) -> Image: ... def toqimage(self): ... def toqpixmap(self): ...