Skip to content

Commit 1334c4d

Browse files
committed
mcp23017.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 44471b7 commit 1334c4d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

adafruit_mcp230xx/mcp23017.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ def get_pin(self, pin):
163163
"""Convenience function to create an instance of the DigitalInOut class
164164
pointing at the specified pin of this MCP23017 device.
165165
"""
166-
assert 0 <= pin <= 15
166+
if not 0 <= pin <= 15:
167+
raise ValueError("Pin number must be 0-15.")
167168
return DigitalInOut(pin, self)
168169

169170
@property

0 commit comments

Comments
 (0)