Skip to content

Commit 6977a1a

Browse files
committed
Change assert to if in get_pin()
Replace assert stmt with if stmt raising a ValueError if pin number is out of bounds.
1 parent a691635 commit 6977a1a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

adafruit_mcp230xx/mcp23008.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,6 @@ def get_pin(self, pin):
8585
"""Convenience function to create an instance of the DigitalInOut class
8686
pointing at the specified pin of this MCP23008 device.
8787
"""
88-
assert 0 <= pin <= 7
88+
if not 0 <= pin <= 7:
89+
raise ValueError("Pin number must be 0-7.")
8990
return DigitalInOut(pin, self)

0 commit comments

Comments
 (0)