diff --git a/PIL/_imaging.pyi b/PIL/_imaging.pyi index f5d691c7c..94ab2e541 100644 --- a/PIL/_imaging.pyi +++ b/PIL/_imaging.pyi @@ -2,7 +2,7 @@ if False: from PIL.aliases import * from typing import Any # temporarily, hopefully ;) - from typing import Optional, List + from typing import Optional, List, Text PILLOW_VERSION = ... DEFAULT_STRATEGY = ... @@ -18,15 +18,20 @@ def blend(core1: ImagingCore, core2: ImagingCore, alpha: float) -> ImagingCore: def fill(mode: Mode, size: Size, color: Any) -> Any: ... def new(mode: Mode, size: Size) -> ImagingCore: ... -def map_buffer(data, size, decoder_name, isNone, isint, args): ... +def map_buffer(target_data: Any, size: Size, decoder_name: Text, + bbox: Optional[Any], offset: int, args: Tuple[Mode, int, int] + ) -> ImagingCore: ... ### what are data & bbox? -def crc32(): ... ### +def crc32(buffer: Any, hilo: Tuple[int, int]=(0,0)) -> Tuple[int, int]: ... +### buffer is bytesarray? Should Tuple[int, int] be another named type? -def effect_mandelbrot(size, extent, quality): ... -def effect_noise(size, sigma): ... -def linear_gradient(mode): ... -def radial_gradient(mode): ... -def wedge(something): ... +def effect_mandelbrot(size: Size=(512,512), + extent: Tuple[float, float, float, float]=(-3,-2.5,2,2.5), + quality: int=100) -> ImagingCore: ... +def effect_noise(size: Size, sigma: float=128) -> ImagingCore: ... +def linear_gradient(mode: Mode) -> ImagingCore: ... +def radial_gradient(mode: Mode) -> ImagingCore: ... +def wedge(mode: Mode) -> ImagingCore: ... class ImagingCore: mode = ... # type: str @@ -39,53 +44,52 @@ class ImagingCore: def putpixel(self, xy: XY, value: Any) -> None: ... def pixel_access(self, readonly: int) -> Any: ... - def convert(self, mode, dither, paletteimage): ... - def convert2(self): ... ### - def convert_matrix(self, a): ... - def convert_transparent(self, a, b): ... + def convert(self, mode: Mode, dither: int=..., paletteimage: Any=...) -> ImagingCore: ... ### what is paletteimage? + def convert2(self, im1: ImagingCore, im2: ImagingCore) -> None: ... + def convert_matrix(self, mode: Mode, matrix: Union[Matrix4, Matrix12]) -> ImagingCore: ... + def convert_transparent(self, mode: Mode, t: Union[Tuple[int, int, int], int]) -> ImagingCore: ... ### Name t better? def copy(self) -> ImagingCore: ... def crop(self, bbox: LURD) -> ImagingCore: ... - def expand(self, xmargin: int, ymargin: int, mode: Mode) -> Any: ... - def filter(self, xy, divisor, offset, kernel): ... - def histogram(self, tuple2: Optional[Any], coremask: Optional[Any]) -> List[int]: ... + def expand(self, xmargin: int, ymargin: int, mode_index: int=0) -> Any: ... ### Include default? + def filter(self, size: Size, divisor: float, offset: float, kernel: Any) -> ImagingCore: ... ### what is kernel? + def histogram(self, tuple2: Tuple[float, float]=..., mask: ImagingCore=...) -> List[int]: ... ### Do these have default values? Do they take None? What is tuple2? def modefilter(self, i: int) -> Any: ... # def offset(self): ... ### Function removed? def paste(self, core: ImagingCore, box: LURD, coremask: ImagingCore) -> None: ... - def point(self, lut, mode): ... - def point_transform(self, scale, offset): ... - def putdata(self, data, scale, offset): ... + def point(self, lut: Any, mode: Optional[Mode]) -> ImagingCore: ... ### Clarify Any + def point_transform(self, scale: float=1.0, offset: float=0.0) -> ImagingCore: ... ### Include defaults or not? + def putdata(self, data: Any, scale: float=1.0, offset: float=0.0) -> None: ... ### Include defaults or not? - def quantize(self, colors, method, kmeans): ... + def quantize(self, colors: int=..., method: int=..., kmeans: int=...) -> ImagingCore: ... - def rankfilter(self): ... ### + def rankfilter(self, size: int, rank: int) -> ImagingCore: ... - def resize(self, size, resample): ... - def transpose(self, method): ... - def transform2(self, box, core, method, data, resample, fill): ... + def resize(self, size: Size, resample: int=...) -> ImagingCore: ... + def transpose(self, method: int) -> ImagingCore: ... + def transform2(self, box: LURD, core: ImagingCore, method: int, data: Any, resample: int=..., fill: int=...) -> None: ... ### What is data? - def isblock(self): ... ### + def isblock(self) -> int: ... def getbbox(self) -> Optional[LURD]: ... - def getcolors(self, maxcolors): ... - def getextrema(self): ... ### - def getprojection(self): ... # returns tuple x, y + def getcolors(self, maxcolors: int) -> List[Tuple[int, Any]]: ... ### Any is a 'Color'? + def getextrema(self) -> Tuple[float, float]: ... + def getprojection(self) -> Tuple[Any, Any]: ... ### Need types - def getband(self, band): ... - # each band has: getextrema() which may return a 2tuple? - def putband(self, alphacore, band): ... - def split(self): ... - def fillband(self, band, alpha): ... + def getband(self, band: int) -> ImagingCore: ... + def putband(self, image: ImagingCore, band_index: int) -> None: ... + def split(self) -> List[ImagingCore]: ... + def fillband(self, band: int, color: int) -> None: ... - def setmode(self, mode): ... + def setmode(self, mode: Mode) -> None: ... - def getpalette(self, mode): ... - def getpalettemode(self): ... ### - def putpalette(self, a): ... - def putpalettealpha(self, a, b): ... - def putpalettealphas(self, a): ... + def getpalette(self, mode: Mode="RGB", rawmode: Mode="RGB") -> Any: ... ### returns bytearray? + def getpalettemode(self) -> Mode: ... + def putpalette(self, rawmode: Mode, palettes) -> None: ... ### palettes is a bytesarray? + def putpalettealpha(self, index: int, alpha: int=...) -> None: ... + def putpalettealphas(self, alphas) -> None: ... ### alphas is a bytesarray? ### chop_* here @@ -93,8 +97,8 @@ class ImagingCore: ### box_blur here - def effect_spread(self, distance): ... + def effect_spread(self, distance: int) -> ImagingCore: ... - def new_block(self): ... ### + def new_block(self, mode: Mode, size: Size) -> ImagingCore: ... - def save_ppm(self, file): ... ### + def save_ppm(self, file: Text) -> None: ...