Skip to content

Commit 1d50128

Browse files
committed
Switch from __bool__ to async is_enabled function
The special patter of making a class object return true or false using __bool__ is for sync code only
1 parent aaa003d commit 1d50128

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/pytac/device.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,6 @@ def get_pv_name(self, handle):
222222
class PvEnabler(object):
223223
"""A PvEnabler class to check whether a device is enabled.
224224
225-
The class will behave like True if the PV value equals enabled_value,
226-
and False otherwise.
227-
228225
.. Private Attributes:
229226
_pv (str): The PV name.
230227
_enabled_value (str): The value for PV for which the device should
@@ -246,11 +243,11 @@ def __init__(self, pv, enabled_value, cs):
246243
self._enabled_value = str(int(float(enabled_value)))
247244
self._cs = cs
248245

249-
async def __bool__(self):
246+
async def is_enabled(self):
250247
"""Used to override the 'if object' clause.
251248
252249
Returns:
253250
bool: True if the device should be considered enabled.
254251
"""
255252
pv_value = await self._cs.get_single(self._pv)
256-
return self._enabled_value == str(int(float(pv_value)))
253+
return self._enabled_value == str(int(float(pv_value))) # ???

0 commit comments

Comments
 (0)