27
27
import adafruit_pypixelbuf as adafruit_pixelbuf
28
28
29
29
30
+ try :
31
+ from typing import Optional , Type
32
+ from types import TracebackType
33
+ except ImportError :
34
+ pass
35
+
36
+
37
+ import microcontroller
38
+
39
+
30
40
__version__ = "0.0.0-auto.0"
31
41
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel.git"
32
42
@@ -102,7 +112,14 @@ class NeoPixel(adafruit_pixelbuf.PixelBuf):
102
112
"""
103
113
104
114
def __init__ (
105
- self , pin , n , * , bpp = 3 , brightness = 1.0 , auto_write = True , pixel_order = None
115
+ self ,
116
+ pin : microcontroller .Pin ,
117
+ n : int ,
118
+ * ,
119
+ bpp : int = 3 ,
120
+ brightness : float = 1.0 ,
121
+ auto_write : bool = True ,
122
+ pixel_order : str = None
106
123
):
107
124
if not pixel_order :
108
125
pixel_order = GRB if bpp == 3 else GRBW
@@ -144,7 +161,12 @@ def deinit(self):
144
161
def __enter__ (self ):
145
162
return self
146
163
147
- def __exit__ (self , exception_type , exception_value , traceback ):
164
+ def __exit__ (
165
+ self ,
166
+ exception_type : Optional [Type [BaseException ]],
167
+ exception_value : Optional [BaseException ],
168
+ traceback : Optional [TracebackType ],
169
+ ):
148
170
self .deinit ()
149
171
150
172
def __repr__ (self ):
@@ -163,5 +185,5 @@ def write(self):
163
185
Use ``show`` instead. It matches Micro:Bit and Arduino APIs."""
164
186
self .show ()
165
187
166
- def _transmit (self , buffer ):
188
+ def _transmit (self , buffer : bytearray ):
167
189
neopixel_write (self .pin , buffer )
0 commit comments