aica-technology / api

AICA API resources
0 stars 0 forks source link

`wait_for` return dict #156

Closed domire8 closed 4 months ago

domire8 commented 5 months ago

https://github.com/aica-technology/api/blob/1416d892dfdab0d2ceeb6a5b8b7733b6a13dda7d/python/src/aica_api/client.py#L279

@eeberhard since #95, the python client wait_for... functions return Union[None,dict] instead of bool. Is this an oversight or is there a reason for it?

@yrh012

eeberhard commented 4 months ago

The changes to read_until were intentional, but the return type of the calling wait_for functions was not intended to change. The wait_for functions should still return True or False depending on if the waiting ended before the timeout or not.

The reason it wasn't caught is that None and a wellformed dict are respectively falsey and truthy when evaluated in a boolean condition such as:

if wait_for_component(...):
    # do something if true
else:
    # do something if false

This can be made more explicitly into a boolean return type using return read_until(...) is not None.

eeberhard commented 4 months ago

I will also use this issue as a springboard to add wait_for_hardware, wait_for_controller and wait_for_controller_predicate, since they are not currently represented.