Skip to content

Commit 824f7ba

Browse files
Update digital_inout.py
1 parent 85974d9 commit 824f7ba

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

adafruit_mcp230xx/digital_inout.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,17 @@ def invert_polarity(self) -> bool:
153153
return True
154154
return False
155155
except AttributeError:
156-
print("IO expander doesn't support inverting polarity! Continuing...")
157156
return False
158157

159158
@invert_polarity.setter
160159
def invert_polarity(self, val: bool) -> None:
161-
try:
162-
if val:
160+
if val:
161+
try:
163162
self._mcp.ipol = _enable_bit(self._mcp.ipol, self._pin)
164-
else:
163+
except AttributeError as error:
164+
raise ValueError("Inverted polarity is not supported.") from error
165+
else:
166+
try:
165167
self._mcp.ipol = _clear_bit(self._mcp.ipol, self._pin)
166-
except AttributeError:
167-
print("IO expander doesn't support inverting polarity! Continuing...")
168+
except AttributeError:
169+
return

0 commit comments

Comments
 (0)