Skip to content

Commit 44471b7

Browse files
committed
mcp23016.py - Change assert to if in get_pin()
Removed assert stmt and added if stmt returning a ValueError if pin number is out of bounds.
1 parent 6977a1a commit 44471b7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

adafruit_mcp230xx/mcp23016.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ def get_pin(self, pin):
126126
"""Convenience function to create an instance of the DigitalInOut class
127127
pointing at the specified pin of this MCP23016 device.
128128
"""
129-
assert 0 <= pin <= 15
129+
if not 0 <= pin <= 15:
130+
raise ValueError("Pin number must be 0-15.")
130131
return DigitalInOut(pin, self)
131132

132133
def clear_inta(self):

0 commit comments

Comments
 (0)