Type obj parameter of PIL.Image.fromarray (#11176)

This commit is contained in:
Avasam
2024-02-05 08:42:52 -05:00
committed by GitHub
parent f11eb92bf4
commit 489e8309b5

View File

@@ -36,6 +36,11 @@ _Color: TypeAlias = (
class _Writeable(SupportsWrite[bytes], Protocol):
def seek(self, __offset: int) -> Any: ...
# Ref: https://numpy.org/doc/stable/reference/arrays.interface.html#python-side
class _SupportsArrayInterface(Protocol):
@property
def __array_interface__(self) -> dict[str, Any]: ...
class DecompressionBombWarning(RuntimeWarning): ...
class DecompressionBombError(Exception): ...
@@ -294,7 +299,9 @@ class ImageTransformHandler: ...
def new(mode: _Mode, size: tuple[int, int], color: _Color = 0) -> Image: ...
def frombytes(mode: _Mode, size: tuple[int, int], data, decoder_name: str = "raw", *args) -> Image: ...
def frombuffer(mode: _Mode, size: tuple[int, int], data, decoder_name: str = "raw", *args) -> Image: ...
def fromarray(obj, mode: _Mode | None = None) -> Image: ...
# If the __array_interface__ has "strides", then `obj` must also support `tobytes` or `tostring`, but we can't enforce that
def fromarray(obj: _SupportsArrayInterface, mode: _Mode | None = None) -> Image: ...
def fromqimage(im) -> Image: ...
def fromqpixmap(im) -> Image: ...
def open(