Skip to content

Commit

Permalink
Bump Pillow to 10.0.*
Browse files Browse the repository at this point in the history
  • Loading branch information
srittau committed Jul 5, 2023
1 parent 29487b8 commit 7d616ce
Show file tree
Hide file tree
Showing 16 changed files with 59 additions and 137 deletions.
6 changes: 6 additions & 0 deletions stubs/Pillow/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@ PIL.XVThumbImagePlugin.r

# Forwarded arguments
PIL\.TiffImagePlugin\.IFDRational\.__[a-z]+__

# Already removed in the 10.0.x branch, but still present in 10.0.0
PIL.Image.MEDIANCUT
PIL.Image.MAXCOVERAGE
PIL.Image.FASTOCTREE
PIL.Image.LIBIMAGEQUANT
2 changes: 1 addition & 1 deletion stubs/Pillow/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "9.5.*"
version = "10.0.*"
partial_stub = true

[tool.stubtest]
Expand Down
10 changes: 0 additions & 10 deletions stubs/Pillow/PIL/BlpImagePlugin.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,16 @@ from .ImageFile import ImageFile, PyDecoder, PyEncoder
class Format(IntEnum):
JPEG: int

BLP_FORMAT_JPEG: Literal[Format.JPEG]

class Encoding(IntEnum):
UNCOMPRESSED: int
DXT: int
UNCOMPRESSED_RAW_BGRA: int

BLP_ENCODING_UNCOMPRESSED: Literal[Encoding.UNCOMPRESSED]
BLP_ENCODING_DXT: Literal[Encoding.DXT]
BLP_ENCODING_UNCOMPRESSED_RAW_BGRA: Literal[Encoding.UNCOMPRESSED_RAW_BGRA]

class AlphaEncoding(IntEnum):
DXT1: int
DXT3: int
DXT5: int

BLP_ALPHA_ENCODING_DXT1: Literal[AlphaEncoding.DXT1]
BLP_ALPHA_ENCODING_DXT3: Literal[AlphaEncoding.DXT3]
BLP_ALPHA_ENCODING_DXT5: Literal[AlphaEncoding.DXT5]

def unpack_565(i): ...
def decode_dxt1(data, alpha: bool = False): ...
def decode_dxt3(data): ...
Expand Down
10 changes: 0 additions & 10 deletions stubs/Pillow/PIL/FitsStubImagePlugin.pyi

This file was deleted.

3 changes: 0 additions & 3 deletions stubs/Pillow/PIL/FtexImagePlugin.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ class Format(IntEnum):
DXT1: int
UNCOMPRESSED: int

FORMAT_DXT1: Literal[Format.DXT1]
FORMAT_UNCOMPRESSED: Literal[Format.UNCOMPRESSED]

class FtexImageFile(ImageFile):
format: ClassVar[Literal["FTEX"]]
format_description: ClassVar[str]
Expand Down
32 changes: 9 additions & 23 deletions stubs/Pillow/PIL/Image.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ from collections.abc import Callable, Iterable, Iterator, MutableMapping, Sequen
from enum import IntEnum
from pathlib import Path
from typing import Any, ClassVar, Protocol, SupportsBytes
from typing_extensions import Literal, Self, TypeAlias
from typing_extensions import Final, Literal, Self, TypeAlias, TypeGuard

from PIL.PyAccess import PyAccess

Expand Down Expand Up @@ -34,21 +34,14 @@ _Color: TypeAlias = int | tuple[int] | tuple[int, int, int] | tuple[int, int, in
class _Writeable(SupportsWrite[bytes], Protocol):
def seek(self, __offset: int) -> Any: ...

NORMAL: Literal[0] # deprecated
SEQUENCE: Literal[1] # deprecated
CONTAINER: Literal[2] # deprecated

class DecompressionBombWarning(RuntimeWarning): ...
class DecompressionBombError(Exception): ...

MAX_IMAGE_PIXELS: int | None
USE_CFFI_ACCESS: Incomplete
MAX_IMAGE_PIXELS: Final[int]

LINEAR: Literal[Resampling.BILINEAR] # deprecated
CUBIC: Literal[Resampling.BICUBIC] # deprecated
ANTIALIAS: Literal[Resampling.LANCZOS] # deprecated
USE_CFFI_ACCESS: bool

def isImageType(t): ...
def isImageType(t: object) -> TypeGuard[Image]: ...

class Transpose(IntEnum):
FLIP_LEFT_RIGHT: Literal[0]
Expand Down Expand Up @@ -124,12 +117,6 @@ class Quantize(IntEnum):
FASTOCTREE: Literal[2]
LIBIMAGEQUANT: Literal[3]

# All Quantize items
MEDIANCUT: Literal[0]
MAXCOVERAGE: Literal[1]
FASTOCTREE: Literal[2]
LIBIMAGEQUANT: Literal[3]

ID: list[str]
OPEN: dict[str, Any]
MIME: dict[str, str]
Expand All @@ -147,20 +134,19 @@ def getmodebandnames(mode: _Mode) -> tuple[str, ...]: ...
def getmodebands(mode: _Mode) -> int: ...
def preinit() -> None: ...
def init() -> None: ...
def coerce_e(value) -> _E: ...

class _E:
scale: Incomplete
data: Incomplete
def __init__(self, scale, data) -> None: ...
def __neg__(self): ...
offset: Incomplete
def __init__(self, scale, offset) -> None: ...
def __neg__(self) -> _E: ...
def __add__(self, other) -> _E: ...
__radd__ = __add__
def __sub__(self, other): ...
def __rsub__(self, other): ...
def __mul__(self, other) -> _E: ...
__rmul__ = __mul__
def __truediv__(self, other): ...
def __truediv__(self, other) -> _E: ...

_ImageState: TypeAlias = tuple[dict[str, Any], str, tuple[int, int], Any, bytes]

Expand Down Expand Up @@ -218,7 +204,7 @@ class Image:
def draft(self, mode: _Mode, size: _Size) -> None: ...
def filter(self, filter: Filter | Callable[[], Filter]) -> Image: ...
def getbands(self) -> tuple[str, ...]: ...
def getbbox(self) -> tuple[int, int, int, int] | None: ...
def getbbox(self, *, alpha_only: bool = True) -> tuple[int, int, int, int] | None: ...
def getcolors(self, maxcolors: int = 256) -> list[tuple[int, int]]: ...
def getdata(self, band: int | None = None): ...
def getextrema(self): ...
Expand Down
10 changes: 0 additions & 10 deletions stubs/Pillow/PIL/ImageCms.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import sys
from _typeshed import Incomplete, Unused
from enum import IntEnum
from typing_extensions import Literal

from .Image import ImagePointHandler

Expand All @@ -15,20 +14,11 @@ class Intent(IntEnum):
SATURATION: int
ABSOLUTE_COLORIMETRIC: int

INTENT_PERCEPTUAL: Literal[Intent.PERCEPTUAL]
INTENT_RELATIVE_COLORIMETRIC: Literal[Intent.RELATIVE_COLORIMETRIC]
INTENT_SATURATION: Literal[Intent.SATURATION]
INTENT_ABSOLUTE_COLORIMETRIC: Literal[Intent.ABSOLUTE_COLORIMETRIC]

class Direction(IntEnum):
INPUT: int
OUTPUT: int
PROOF: int

DIRECTION_INPUT: Literal[Direction.INPUT]
DIRECTION_OUTPUT: Literal[Direction.OUTPUT]
DIRECTION_PROOF: Literal[Direction.PROOF]

FLAGS: Incomplete

class ImageCmsProfile:
Expand Down
21 changes: 1 addition & 20 deletions stubs/Pillow/PIL/ImageDraw.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class ImageDraw:
rotation: float = 0,
fill: _Ink | None = None,
outline: _Ink | None = None,
width: float = 1,
) -> None: ...
def rectangle(
self,
Expand Down Expand Up @@ -99,26 +100,6 @@ class ImageDraw:
stroke_fill: _Ink | None = None,
embedded_color: bool = False,
) -> None: ...
def textsize(
self,
text: str | bytes,
font: _Font | None = None,
spacing: float = 4,
direction: Literal["rtl", "ltr", "ttb"] | None = None,
features: Sequence[str] | None = None,
language: str | None = None,
stroke_width: int = 0,
) -> tuple[int, int]: ...
def multiline_textsize(
self,
text: str | bytes,
font: _Font | None = None,
spacing: float = 4,
direction: Literal["rtl", "ltr", "ttb"] | None = None,
features: Sequence[str] | None = None,
language: str | None = None,
stroke_width: int = 0,
) -> tuple[int, int]: ...
def textlength(
self,
text: str | bytes,
Expand Down
12 changes: 7 additions & 5 deletions stubs/Pillow/PIL/ImageDraw2.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from _typeshed import Incomplete

from .Image import Image
from .ImageDraw import ImageDraw

class Pen:
color: Incomplete
width: Incomplete
Expand All @@ -15,11 +18,11 @@ class Font:
def __init__(self, color, file, size: int = 12) -> None: ...

class Draw:
draw: Incomplete
image: Incomplete
transform: Incomplete
draw: ImageDraw
image: Image
transform: Incomplete | None
def __init__(self, image, size: Incomplete | None = None, color: Incomplete | None = None) -> None: ...
def flush(self): ...
def flush(self) -> Image: ...
def render(self, op, xy, pen, brush: Incomplete | None = None) -> None: ...
def settransform(self, offset) -> None: ...
def arc(self, xy, start, end, *options) -> None: ...
Expand All @@ -30,6 +33,5 @@ class Draw:
def polygon(self, xy, *options) -> None: ...
def rectangle(self, xy, *options) -> None: ...
def text(self, xy, text, font) -> None: ...
def textsize(self, text, font): ...
def textbbox(self, xy, text, font): ...
def textlength(self, text, font): ...
36 changes: 8 additions & 28 deletions stubs/Pillow/PIL/ImageFont.pyi
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
from _typeshed import FileDescriptorOrPath, Incomplete, SupportsRead
from enum import IntEnum
from typing import Protocol
from typing_extensions import Literal
from typing_extensions import Final, Literal

from PIL.Image import Transpose

class Layout(IntEnum):
BASIC: Literal[0]
RAQM: Literal[1]

LAYOUT_BASIC: Literal[Layout.BASIC]
LAYOUT_RAQM: Literal[Layout.RAQM]
MAX_STRING_LENGTH: Final[int] = 1_000_000

class _Font(Protocol):
def getmask(self, text: str | bytes, mode: str = ..., direction=..., features=...): ...

class ImageFont:
def getsize(self, text: str | bytes, *args, **kwargs) -> tuple[int, int]: ...
def getmask(self, text: str | bytes, mode: str = "", direction=..., features=...): ...
def getbbox(self, text, *args, **kwargs): ...
def getlength(self, text, *args, **kwargs): ...
Expand All @@ -25,7 +25,7 @@ class FreeTypeFont:
index: int
encoding: str
layout_engine: Layout
font_bytes: Incomplete
font_bytes: bytes # Only exists under some circumstances.
font: Incomplete
def __init__(
self,
Expand Down Expand Up @@ -55,24 +55,6 @@ class FreeTypeFont:
stroke_width: int = 0,
anchor: str | None = None,
) -> tuple[int, int, int, int]: ...
def getsize(
self,
text: str | bytes,
direction: Literal["ltr", "rtl", "ttb"] | None = None,
features: Incomplete | None = None,
language: str | None = None,
stroke_width: int = 0,
) -> tuple[int, int]: ...
def getsize_multiline(
self,
text: str | bytes,
direction: Literal["ltr", "rtl", "ttb"] | None = None,
spacing: float = 4,
features: Incomplete | None = None,
language: str | None = None,
stroke_width: float = 0,
) -> tuple[int, int]: ...
def getoffset(self, text: str | bytes) -> tuple[int, int]: ...
def getmask(
self,
text: str | bytes,
Expand All @@ -89,7 +71,6 @@ class FreeTypeFont:
self,
text: str | bytes,
mode: str = "",
fill=...,
direction: Literal["ltr", "rtl", "ttb"] | None = None,
features: Incomplete | None = None,
language: str | None = None,
Expand All @@ -114,10 +95,9 @@ class FreeTypeFont:
def set_variation_by_axes(self, axes): ...

class TransposedFont:
font: Incomplete
orientation: Incomplete
def __init__(self, font: _Font, orientation: int | None = None) -> None: ...
def getsize(self, text: str | bytes, *args, **kwargs) -> tuple[int, int]: ...
font: _Font
orientation: Transpose | None
def __init__(self, font: _Font, orientation: Transpose | None = None) -> None: ...
def getmask(self, text: str | bytes, mode: str = "", *args, **kwargs): ...
def getbbox(self, text, *args, **kwargs): ...
def getlength(self, text, *args, **kwargs): ...
Expand Down
2 changes: 1 addition & 1 deletion stubs/Pillow/PIL/ImageOps.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ def invert(image: Image) -> Image: ...
def mirror(image: Image) -> Image: ...
def posterize(image: Image, bits: int) -> Image: ...
def solarize(image: Image, threshold: int = 128) -> Image: ...
def exif_transpose(image: Image) -> Image: ...
def exif_transpose(image: Image, *, in_place: bool = False) -> Image: ...
2 changes: 1 addition & 1 deletion stubs/Pillow/PIL/ImagePalette.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class ImagePalette:
palette: Incomplete
colors: Incomplete
dirty: Incomplete
def __init__(self, mode: str = "RGB", palette: Incomplete | None = None, size: int = 0) -> None: ...
def __init__(self, mode: str = "RGB", palette: Incomplete | None = None) -> None: ...
def copy(self) -> ImagePalette: ...
def getdata(self): ...
def tobytes(self) -> bytes: ...
Expand Down
Loading

0 comments on commit 7d616ce

Please sign in to comment.