Skip to content

Commit f3bfd6d

Browse files
committed
Use try/except instead of non-existent property
1 parent 5fa3a28 commit f3bfd6d

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

adafruit_motor/stepper.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,13 @@ def __init__(
114114
self._coil = (ain2, bin1, ain1, bin2)
115115
for i in range(4):
116116
if self._coil[i].frequency < 1500:
117-
if (
118-
hasattr(self._coil[i], "variable_frequency")
119-
and not self._coil[i].variable_frequency
120-
):
117+
try:
118+
self._coil[i].frequency = 2000
119+
except AttributeError:
121120
raise ValueError(
122121
"PWMOut outputs must either be set to at least "
123122
"1500 Hz or allow variable frequency."
124123
)
125-
self._coil[i].frequency = 2000
126124
if microsteps < 2:
127125
raise ValueError("Microsteps must be at least 2")
128126
if microsteps % 2 == 1:

0 commit comments

Comments
 (0)