]> Repositories - Adafruit_Blinka-hackapet.git/commitdiff
Move import busio back to where it was
authorMelissa LeBlanc-Williams <melissa@adafruit.com>
Thu, 6 May 2021 20:48:20 +0000 (13:48 -0700)
committerMelissa LeBlanc-Williams <melissa@adafruit.com>
Thu, 6 May 2021 20:48:20 +0000 (13:48 -0700)
src/board.py

index 1b42b53211399f7606e65571a2489d735d4f5cd7..3852a77a5bf27c5956af816624b6bd7d6392a4d0 100755 (executable)
@@ -31,9 +31,9 @@ import sys
 
 import adafruit_platformdetect.constants.boards as ap_board
 from adafruit_blinka.agnostic import board_id, detector
-import busio
 
 # pylint: disable=wildcard-import,unused-wildcard-import,ungrouped-imports
+# pylint: disable=import-outside-toplevel
 
 if board_id == ap_board.FEATHER_HUZZAH:
     from adafruit_blinka.board.feather_huzzah import *
@@ -225,17 +225,24 @@ else:
     raise NotImplementedError("Board not supported {}".format(board_id))
 
 try:
-    if SDA and SCL:
 
-        def I2C():
-            """The singleton I2C interface"""
-            return busio.I2C(SCL, SDA)
+    def I2C():
+        """The singleton I2C interface"""
+        import busio
 
-    if SCLK:
+        return busio.I2C(SCL, SDA)
 
-        def SPI():
-            """The singleton SPI interface"""
-            return busio.SPI(SCLK, MOSI, MISO)
+
+except NameError:
+    pass
+
+try:
+
+    def SPI():
+        """The singleton SPI interface"""
+        import busio
+
+        return busio.SPI(SCLK, MOSI, MISO)
 
 
 except NameError: