From 44471b71a272bc5688a22ccd753a1cbeb45bcca3 Mon Sep 17 00:00:00 2001 From: PRC-SAK Date: Wed, 10 Feb 2021 20:36:03 -0800 Subject: [PATCH] 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. --- adafruit_mcp230xx/mcp23016.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adafruit_mcp230xx/mcp23016.py b/adafruit_mcp230xx/mcp23016.py index 3fcdbf5..a68306b 100644 --- a/adafruit_mcp230xx/mcp23016.py +++ b/adafruit_mcp230xx/mcp23016.py @@ -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):