Skip to content

Replace assert with if statement (Fixes #32) #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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