You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Testing ca_nothing for boolean needs to be deprecated #67
As discussed in DiamondLightSource/aioca#45 it would appear that allowing a ca_nothing value to return False to a boolean test triggers unexpected behaviour: it turns out that Exception subclasses are expected by core Python libraries to return True when tested with __bool__.
The obvious fix is to delete the implementation of ca_nothing.__bool__ here:
but unfortunately this is a breaking change for any code which is testing bool(value) rather than value.ok. The only reasonable solution is probably to raise a one-shot deprecation warning when this function is called.
Fortunately I don't think the boolean test feature of ca_nothing is documented, but this still needs to be flagged as a breaking change.
Activity
Araneidae commentedon Jul 9, 2024
Unfortunately not only is this documented behaviour, it is recommended:
cothread/docs/user/catools.rst
Lines 218 to 223 in bb62450
Araneidae commentedon Dec 2, 2024
The patch described in DiamondLightSource/aioca#45 (comment) should probably be applied to cothread.