File tree Expand file tree Collapse file tree 6 files changed +46
-9
lines changed Expand file tree Collapse file tree 6 files changed +46
-9
lines changed Original file line number Diff line number Diff line change 15
15
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Typing.git"
16
16
17
17
import array
18
- from typing import Union , Optional
19
- from typing_extensions import Protocol , TypeAlias # Safety import for Python 3.7
18
+ from typing import TYPE_CHECKING , Optional , Union
19
+
20
+ # Protocol was introduced in Python 3.8, TypeAlias in 3.10
21
+ from typing_extensions import Protocol , TypeAlias
22
+
23
+ # pylint: disable=used-before-assignment
24
+ if TYPE_CHECKING :
25
+ import alarm
26
+ import audiocore
27
+ import audiomixer
28
+ import audiomp3
29
+ import rgbmatrix
30
+ import synthio
31
+ import ulab
32
+ from alarm .pin import PinAlarm
33
+ from alarm .time import TimeAlarm
34
+ from ulab .numpy import ndarray
35
+
20
36
21
37
# Lists below are alphabetized.
22
38
Original file line number Diff line number Diff line change 11
11
* Author(s): Alec Delaney
12
12
"""
13
13
14
+ from adafruit_requests import Response
15
+
14
16
# Protocol was introduced in Python 3.8.
15
17
from typing_extensions import Protocol
16
- from adafruit_requests import Response
17
18
18
19
19
20
class HTTPProtocol (Protocol ):
Original file line number Diff line number Diff line change @@ -38,7 +38,11 @@ def value(self) -> float:
38
38
on the specifics of the class.
39
39
"""
40
40
41
+ # TODO: this should be `value(self, input_value: float, /)` but can't
42
+ # because currently mpy files are built and the `/` param isn't supported
43
+ # in micro-python.
44
+ # https://github.com/adafruit/Adafruit_CircuitPython_Typing/issues/36
41
45
# pylint: disable=no-self-use,unused-argument
42
46
@value .setter
43
- def value (self , input_value : float , / ):
47
+ def value (self , input_value : float ):
44
48
...
Original file line number Diff line number Diff line change 11
11
* Author(s): Alec Delaney
12
12
"""
13
13
14
+ from typing import Tuple , Union
15
+
14
16
# Protocol was introduced in Python 3.8, TypeAlias in 3.10
15
- from typing import Union , Tuple
16
17
from typing_extensions import Protocol , TypeAlias
17
18
18
19
ColorBasedColorUnion : TypeAlias = Union [int , Tuple [int , int , int ]]
Original file line number Diff line number Diff line change 11
11
* Author(s): Alec Delaney
12
12
"""
13
13
14
- from typing import Tuple , Optional , Callable
15
- from typing_extensions import Protocol # Safety import for Python 3.7
14
+ from typing import Callable , Optional , Tuple
15
+
16
+ # Protocol was introduced in Python 3.8
17
+ from typing_extensions import Protocol
16
18
17
19
18
20
class PixelAccess (Protocol ):
Original file line number Diff line number Diff line change 16
16
# Protocol was introduced in Python 3.8, TypeAlias in 3.10
17
17
from typing_extensions import Protocol , TypeAlias
18
18
19
-
20
19
# Based on https://github.com/python/typeshed/blob/master/stdlib/_socket.pyi
21
20
22
21
__all__ = [
@@ -126,4 +125,18 @@ def TLS_MODE(self) -> int: # pylint: disable=invalid-name
126
125
"""Constant representing that a socket's connection mode is TLS."""
127
126
128
127
129
- SSLContextType : TypeAlias = Union [SSLContext , "_FakeSSLContext" ]
128
+ # pylint: disable=too-few-public-methods
129
+ class _FakeSSLSocket :
130
+ """Describes the structure every fake SSL socket type must have."""
131
+
132
+
133
+ class _FakeSSLContext :
134
+ """Describes the structure every fake SSL context type must have."""
135
+
136
+ def wrap_socket (
137
+ self , socket : CircuitPythonSocketType , server_hostname : Optional [str ] = None
138
+ ) -> _FakeSSLSocket :
139
+ """Wrap socket and return a new one that uses the methods from the original."""
140
+
141
+
142
+ SSLContextType : TypeAlias = Union [SSLContext , _FakeSSLContext ]
You can’t perform that action at this time.
0 commit comments