Skip to content

Commit 3094ab3

Browse files
committed
define I2C if busio.I2C import fails
1 parent f096ca8 commit 3094ab3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

adafruit_ina219.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@
3737
import typing # pylint: disable=unused-import
3838
from busio import I2C
3939
except ImportError:
40-
pass
40+
# define I2C to avoid the error:
41+
# def __init__(self, i2c_bus: I2C, addr: int = 0x40) -> None:
42+
# NameError: name 'I2C' is not defined
43+
I2C = None
4144

4245
__version__ = "0.0.0+auto.0"
4346
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_INA219.git"

0 commit comments

Comments
 (0)