Skip to content

Commit

Permalink
Merge pull request #39 from SAK917/master
Browse files Browse the repository at this point in the history
Replace assert with if statement (Fixes #32)
  • Loading branch information
ladyada authored Feb 11, 2021
2 parents a691635 + 1334c4d commit c84c901
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion adafruit_mcp230xx/mcp23008.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,6 @@ def get_pin(self, pin):
"""Convenience function to create an instance of the DigitalInOut class
pointing at the specified pin of this MCP23008 device.
"""
assert 0 <= pin <= 7
if not 0 <= pin <= 7:
raise ValueError("Pin number must be 0-7.")
return DigitalInOut(pin, self)
3 changes: 2 additions & 1 deletion adafruit_mcp230xx/mcp23016.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ def get_pin(self, pin):
"""Convenience function to create an instance of the DigitalInOut class
pointing at the specified pin of this MCP23016 device.
"""
assert 0 <= pin <= 15
if not 0 <= pin <= 15:
raise ValueError("Pin number must be 0-15.")
return DigitalInOut(pin, self)

def clear_inta(self):
Expand Down
3 changes: 2 additions & 1 deletion adafruit_mcp230xx/mcp23017.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ def get_pin(self, pin):
"""Convenience function to create an instance of the DigitalInOut class
pointing at the specified pin of this MCP23017 device.
"""
assert 0 <= pin <= 15
if not 0 <= pin <= 15:
raise ValueError("Pin number must be 0-15.")
return DigitalInOut(pin, self)

@property
Expand Down

0 comments on commit c84c901

Please sign in to comment.