Skip to content

Commit c84c901

Browse files
authored
Merge pull request #39 from SAK917/master
Replace assert with if statement (Fixes #32)
2 parents a691635 + 1334c4d commit c84c901

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
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)

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):

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)