Type annotations: _imaging.pyi: Significantly improve stubs.

This commit is contained in:
neiljp (Neil Pilgrim) 2017-08-20 11:18:15 -07:00 committed by Eric Soroos
parent cf043ed16e
commit 48e183eaf1

View File

@ -2,7 +2,7 @@ if False:
from PIL.aliases import * from PIL.aliases import *
from typing import Any # temporarily, hopefully ;) from typing import Any # temporarily, hopefully ;)
from typing import Optional, List from typing import Optional, List, Text
PILLOW_VERSION = ... PILLOW_VERSION = ...
DEFAULT_STRATEGY = ... 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 fill(mode: Mode, size: Size, color: Any) -> Any: ...
def new(mode: Mode, size: Size) -> ImagingCore: ... 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_mandelbrot(size: Size=(512,512),
def effect_noise(size, sigma): ... extent: Tuple[float, float, float, float]=(-3,-2.5,2,2.5),
def linear_gradient(mode): ... quality: int=100) -> ImagingCore: ...
def radial_gradient(mode): ... def effect_noise(size: Size, sigma: float=128) -> ImagingCore: ...
def wedge(something): ... def linear_gradient(mode: Mode) -> ImagingCore: ...
def radial_gradient(mode: Mode) -> ImagingCore: ...
def wedge(mode: Mode) -> ImagingCore: ...
class ImagingCore: class ImagingCore:
mode = ... # type: str mode = ... # type: str
@ -39,53 +44,52 @@ class ImagingCore:
def putpixel(self, xy: XY, value: Any) -> None: ... def putpixel(self, xy: XY, value: Any) -> None: ...
def pixel_access(self, readonly: int) -> Any: ... def pixel_access(self, readonly: int) -> Any: ...
def convert(self, mode, dither, paletteimage): ... def convert(self, mode: Mode, dither: int=..., paletteimage: Any=...) -> ImagingCore: ... ### what is paletteimage?
def convert2(self): ... ### def convert2(self, im1: ImagingCore, im2: ImagingCore) -> None: ...
def convert_matrix(self, a): ... def convert_matrix(self, mode: Mode, matrix: Union[Matrix4, Matrix12]) -> ImagingCore: ...
def convert_transparent(self, a, b): ... def convert_transparent(self, mode: Mode, t: Union[Tuple[int, int, int], int]) -> ImagingCore: ... ### Name t better?
def copy(self) -> ImagingCore: ... def copy(self) -> ImagingCore: ...
def crop(self, bbox: LURD) -> ImagingCore: ... def crop(self, bbox: LURD) -> ImagingCore: ...
def expand(self, xmargin: int, ymargin: int, mode: Mode) -> Any: ... def expand(self, xmargin: int, ymargin: int, mode_index: int=0) -> Any: ... ### Include default?
def filter(self, xy, divisor, offset, kernel): ... def filter(self, size: Size, divisor: float, offset: float, kernel: Any) -> ImagingCore: ... ### what is kernel?
def histogram(self, tuple2: Optional[Any], coremask: Optional[Any]) -> List[int]: ... 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 modefilter(self, i: int) -> Any: ...
# def offset(self): ... ### Function removed? # def offset(self): ... ### Function removed?
def paste(self, core: ImagingCore, box: LURD, coremask: ImagingCore) -> None: ... def paste(self, core: ImagingCore, box: LURD, coremask: ImagingCore) -> None: ...
def point(self, lut, mode): ... def point(self, lut: Any, mode: Optional[Mode]) -> ImagingCore: ... ### Clarify Any
def point_transform(self, scale, offset): ... def point_transform(self, scale: float=1.0, offset: float=0.0) -> ImagingCore: ... ### Include defaults or not?
def putdata(self, data, scale, offset): ... 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 resize(self, size: Size, resample: int=...) -> ImagingCore: ...
def transpose(self, method): ... def transpose(self, method: int) -> ImagingCore: ...
def transform2(self, box, core, method, data, resample, fill): ... 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 getbbox(self) -> Optional[LURD]: ...
def getcolors(self, maxcolors): ... def getcolors(self, maxcolors: int) -> List[Tuple[int, Any]]: ... ### Any is a 'Color'?
def getextrema(self): ... ### def getextrema(self) -> Tuple[float, float]: ...
def getprojection(self): ... # returns tuple x, y def getprojection(self) -> Tuple[Any, Any]: ... ### Need types
def getband(self, band): ... def getband(self, band: int) -> ImagingCore: ...
# each band has: getextrema() which may return a 2tuple? def putband(self, image: ImagingCore, band_index: int) -> None: ...
def putband(self, alphacore, band): ... def split(self) -> List[ImagingCore]: ...
def split(self): ... def fillband(self, band: int, color: int) -> None: ...
def fillband(self, band, alpha): ...
def setmode(self, mode): ... def setmode(self, mode: Mode) -> None: ...
def getpalette(self, mode): ... def getpalette(self, mode: Mode="RGB", rawmode: Mode="RGB") -> Any: ... ### returns bytearray?
def getpalettemode(self): ... ### def getpalettemode(self) -> Mode: ...
def putpalette(self, a): ... def putpalette(self, rawmode: Mode, palettes) -> None: ... ### palettes is a bytesarray?
def putpalettealpha(self, a, b): ... def putpalettealpha(self, index: int, alpha: int=...) -> None: ...
def putpalettealphas(self, a): ... def putpalettealphas(self, alphas) -> None: ... ### alphas is a bytesarray?
### chop_* here ### chop_* here
@ -93,8 +97,8 @@ class ImagingCore:
### box_blur here ### 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: ...