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 1515__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Typing.git"
1616
1717import 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+
2036
2137# Lists below are alphabetized.
2238
Original file line number Diff line number Diff line change 1111* Author(s): Alec Delaney
1212"""
1313
14+ from adafruit_requests import Response
15+
1416# Protocol was introduced in Python 3.8.
1517from typing_extensions import Protocol
16- from adafruit_requests import Response
1718
1819
1920class HTTPProtocol (Protocol ):
Original file line number Diff line number Diff line change @@ -38,7 +38,11 @@ def value(self) -> float:
3838 on the specifics of the class.
3939 """
4040
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
4145 # pylint: disable=no-self-use,unused-argument
4246 @value .setter
43- def value (self , input_value : float , / ):
47+ def value (self , input_value : float ):
4448 ...
Original file line number Diff line number Diff line change 1111* Author(s): Alec Delaney
1212"""
1313
14+ from typing import Tuple , Union
15+
1416# Protocol was introduced in Python 3.8, TypeAlias in 3.10
15- from typing import Union , Tuple
1617from typing_extensions import Protocol , TypeAlias
1718
1819ColorBasedColorUnion : TypeAlias = Union [int , Tuple [int , int , int ]]
Original file line number Diff line number Diff line change 1111* Author(s): Alec Delaney
1212"""
1313
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
1618
1719
1820class PixelAccess (Protocol ):
Original file line number Diff line number Diff line change 1616# Protocol was introduced in Python 3.8, TypeAlias in 3.10
1717from typing_extensions import Protocol , TypeAlias
1818
19-
2019# Based on https://github.com/python/typeshed/blob/master/stdlib/_socket.pyi
2120
2221__all__ = [
@@ -126,4 +125,18 @@ def TLS_MODE(self) -> int: # pylint: disable=invalid-name
126125 """Constant representing that a socket's connection mode is TLS."""
127126
128127
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