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