Skip to content

Commit 29083f9

Browse files
committed
Moved typing-related imports into try/except block
1 parent fabe0e9 commit 29083f9

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

neopixel.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,14 @@
2828

2929

3030
try:
31+
# Used only for typing
3132
from typing import Optional, Type
3233
from types import TracebackType
34+
import microcontroller
3335
except ImportError:
3436
pass
3537

3638

37-
import microcontroller
38-
39-
4039
__version__ = "0.0.0-auto.0"
4140
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel.git"
4241

@@ -150,7 +149,7 @@ def __init__(
150149
self.pin = digitalio.DigitalInOut(pin)
151150
self.pin.direction = digitalio.Direction.OUTPUT
152151

153-
def deinit(self):
152+
def deinit(self) -> None:
154153
"""Blank out the NeoPixels and release the pin."""
155154
self.fill(0)
156155
self.show()
@@ -173,17 +172,17 @@ def __repr__(self):
173172
return "[" + ", ".join([str(x) for x in self]) + "]"
174173

175174
@property
176-
def n(self):
175+
def n(self) -> int:
177176
"""
178177
The number of neopixels in the chain (read-only)
179178
"""
180179
return len(self)
181180

182-
def write(self):
181+
def write(self) -> None:
183182
""".. deprecated: 1.0.0
184183
185184
Use ``show`` instead. It matches Micro:Bit and Arduino APIs."""
186185
self.show()
187186

188-
def _transmit(self, buffer: bytearray):
187+
def _transmit(self, buffer: bytearray) -> None:
189188
neopixel_write(self.pin, buffer)

0 commit comments

Comments
 (0)