diff --git a/stubs/Pillow/METADATA.toml b/stubs/Pillow/METADATA.toml index 0d4c0a4bd..cb3899bf2 100644 --- a/stubs/Pillow/METADATA.toml +++ b/stubs/Pillow/METADATA.toml @@ -1 +1 @@ -version = "8.2" +version = "8.3" diff --git a/stubs/Pillow/PIL/Image.pyi b/stubs/Pillow/PIL/Image.pyi index f5313db9c..6375cc30c 100644 --- a/stubs/Pillow/PIL/Image.pyi +++ b/stubs/Pillow/PIL/Image.pyi @@ -120,8 +120,7 @@ class Image: def __exit__(self, *args: Any) -> None: ... def close(self) -> None: ... def __eq__(self, other: object) -> bool: ... - @property - def __array_interface__(self) -> dict[str, Any]: ... + def __array__(self) -> Any: ... # returns numpy.array() def __getstate__(self) -> _ImageState: ... def __setstate__(self, state: _ImageState) -> None: ... def tobytes(self, encoder_name: str = ..., *args) -> bytes: ... @@ -173,7 +172,7 @@ class Image: def resize( self, size: tuple[int, int], - resample: _Resample = ..., + resample: _Resample | None = ..., box: tuple[float, float, float, float] | None = ..., reducing_gap: float | None = ..., ) -> Image: ... @@ -187,7 +186,15 @@ class Image: translate: tuple[float, float] | None = ..., fillcolor: _Color | None = ..., ) -> Image: ... - def save(self, fp: str | bytes | Path | _Writeable, format: str | None = ..., **params: Any) -> None: ... + def save( + self, + fp: str | bytes | Path | _Writeable, + format: str | None = ..., + *, + save_all: bool = ..., + bitmap_format: Literal["bmp", "png"] = ..., # for ICO files + **params: Any, + ) -> None: ... def seek(self, frame: int) -> None: ... def show(self, title: str | None = ..., command: str | None = ...) -> None: ... def split(self) -> Tuple[Image, ...]: ... diff --git a/stubs/Pillow/PIL/ImageOps.pyi b/stubs/Pillow/PIL/ImageOps.pyi index 3322b90e5..bff43f61b 100644 --- a/stubs/Pillow/PIL/ImageOps.pyi +++ b/stubs/Pillow/PIL/ImageOps.pyi @@ -17,6 +17,7 @@ def colorize( whitepoint: int = ..., midpoint: int = ..., ) -> Image: ... +def contain(image: Image, size: _Size, method: _Resample = ...) -> Image: ... def pad( image: Image, size: _Size, method: _Resample = ..., color: Any | None = ..., centering: Iterable[float] = ... ) -> Image: ... diff --git a/stubs/Pillow/PIL/ImagePalette.pyi b/stubs/Pillow/PIL/ImagePalette.pyi index 63b8b6ce8..7e1f80e1b 100644 --- a/stubs/Pillow/PIL/ImagePalette.pyi +++ b/stubs/Pillow/PIL/ImagePalette.pyi @@ -1,5 +1,7 @@ from typing import Any +from .Image import Image + class ImagePalette: mode: Any rawmode: Any @@ -11,7 +13,7 @@ class ImagePalette: def getdata(self): ... def tobytes(self) -> bytes: ... tostring = tobytes - def getcolor(self, color: tuple[int, int, int]) -> int: ... + def getcolor(self, color: tuple[int, int, int], image: Image | None = ...) -> int: ... def save(self, fp) -> None: ... def raw(rawmode, data): ... diff --git a/stubs/Pillow/PIL/PSDraw.pyi b/stubs/Pillow/PIL/PSDraw.pyi index ccf61e4a5..2386f284a 100644 --- a/stubs/Pillow/PIL/PSDraw.pyi +++ b/stubs/Pillow/PIL/PSDraw.pyi @@ -1,12 +1,12 @@ -from typing import Any +from _typeshed import SupportsWrite from .Image import Image class PSDraw: - fp: Any - def __init__(self, fp: Any | None = ...) -> None: ... - isofont: Any - def begin_document(self, id: Any | None = ...) -> None: ... + fp: SupportsWrite[bytes] + def __init__(self, fp: SupportsWrite[bytes] | None = ...) -> None: ... + isofont: dict[bytes, int] + def begin_document(self, id: object | None = ...) -> None: ... def end_document(self) -> None: ... def setfont(self, font: str, size: int) -> None: ... def line(self, xy0: tuple[int, int], xy1: tuple[int, int]) -> None: ... @@ -14,6 +14,6 @@ class PSDraw: def text(self, xy: tuple[int, int], text: str) -> None: ... def image(self, box: tuple[int, int, int, int], im: Image, dpi: float | None = ...) -> None: ... -EDROFF_PS: str -VDI_PS: str -ERROR_PS: str +EDROFF_PS: bytes +VDI_PS: bytes +ERROR_PS: bytes diff --git a/stubs/Pillow/PIL/TiffImagePlugin.pyi b/stubs/Pillow/PIL/TiffImagePlugin.pyi index 3b9aea231..5eaaa7b6f 100644 --- a/stubs/Pillow/PIL/TiffImagePlugin.pyi +++ b/stubs/Pillow/PIL/TiffImagePlugin.pyi @@ -88,10 +88,13 @@ class IFDRational(Rational): __round__: Any class ImageFileDirectory_v2(MutableMapping[int, Any]): + group: int | None tagtype: dict[int, int] - def __init__(self, ifh: bytes = ..., prefix: Any | None = ...) -> None: ... - prefix: Any - offset: Any + def __init__(self, ifh: bytes = ..., prefix: bytes | None = ..., group: int | None = ...) -> None: ... + @property + def prefix(self) -> bytes: ... + @property + def offset(self) -> int | None: ... @property def legacy_api(self) -> bool: ... def reset(self) -> None: ... diff --git a/stubs/Pillow/PIL/TiffTags.pyi b/stubs/Pillow/PIL/TiffTags.pyi index 78dae91b2..5559e169b 100644 --- a/stubs/Pillow/PIL/TiffTags.pyi +++ b/stubs/Pillow/PIL/TiffTags.pyi @@ -1,27 +1,45 @@ -from typing import Any +from typing import Any, Dict, NamedTuple, Tuple, Union +from typing_extensions import Literal -class TagInfo: +class _TagInfo(NamedTuple): + value: Any + name: str + type: _TagType + length: int + enum: dict[str, int] + +class TagInfo(_TagInfo): def __new__( - cls, value: Any | None = ..., name: str = ..., type: Any | None = ..., length: Any | None = ..., enum: Any | None = ... + cls, + value: Any | None = ..., + name: str = ..., + type: _TagType | None = ..., + length: int | None = ..., + enum: dict[str, int] | None = ..., ): ... def cvt_enum(self, value): ... -def lookup(tag): ... +def lookup(tag: int, group: int | None = ...) -> _TagInfo: ... -BYTE: int -ASCII: int -SHORT: int -LONG: int -RATIONAL: int -SIGNED_BYTE: int -UNDEFINED: int -SIGNED_SHORT: int -SIGNED_LONG: int -SIGNED_RATIONAL: int -FLOAT: int -DOUBLE: int -IFD: int -TAGS_V2: Any -TAGS: Any -TYPES: Any -LIBTIFF_CORE: Any +BYTE: Literal[1] +ASCII: Literal[2] +SHORT: Literal[3] +LONG: Literal[4] +RATIONAL: Literal[5] +SIGNED_BYTE: Literal[6] +UNDEFINED: Literal[7] +SIGNED_SHORT: Literal[8] +SIGNED_LONG: Literal[9] +SIGNED_RATIONAL: Literal[10] +FLOAT: Literal[11] +DOUBLE: Literal[12] +IFD: Literal[13] + +_TagType = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] +_TagTuple = Union[Tuple[str, _TagType, int], Tuple[str, _TagInfo, int, Dict[str, int]]] + +TAGS_V2: dict[int, _TagTuple] +TAGS_V2_GROUPS: dict[int, dict[int, _TagTuple]] +TAGS: dict[int, str] +TYPES: dict[int, str] +LIBTIFF_CORE: set[int]