File tree 1 file changed +47
-0
lines changed
1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ # SPDX-FileCopyrightText: Copyright (c) 2022 Alec Delaney
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+
5
+ """
6
+ `circuitpython_typing.pil`
7
+ ================================================================================
8
+
9
+ Type annotation definitions for PIL Images.
10
+
11
+ * Author(s): Alec Delaney
12
+ """
13
+
14
+ from typing import Tuple
15
+
16
+ # Protocol was introduced in Python 3.8.
17
+ try :
18
+ from typing import Protocol
19
+ except ImportError :
20
+ from typing_extensions import Protocol
21
+
22
+
23
+ class PixelAccess (Protocol ):
24
+ """Type annotation for PIL's PixelAccess class"""
25
+
26
+ # pylint: disable=invalid-name
27
+ def __getitem__ (self , xy : Tuple [int , int ]) -> int :
28
+ """Get pixels by x, y coordinate"""
29
+ ...
30
+
31
+
32
+ class Image (Protocol ):
33
+ """Type annotation for PIL's Image class"""
34
+
35
+ @property
36
+ def mode (self ) -> str :
37
+ """The mode of the image"""
38
+ ...
39
+
40
+ @property
41
+ def size (self ) -> Tuple [int , int ]:
42
+ """The size of the image"""
43
+ ...
44
+
45
+ def load (self ) -> PixelAccess :
46
+ """Load the image for quick pixel access"""
47
+ ...
You can’t perform that action at this time.
0 commit comments