The ui implementations of requesting user input have a flaw when returning results.
This is due to the validator functions returning a Union of validated input and False . The ui functions then blindly convert the result to a boolean and loop without feedback if a false value is received from the input validator. If a valid input converts to false, then the input is discarded.
I found this happening specifically with user_input_float as 0 or 0.0 are valid floats.
In cmd_line.py
for _ in range(attempts):
# This will change based on the interface
print("\a")
ret_val = input(msg)
if target is None:
q.put(ret_val)
return
ret_val = target(ret_val, **kwargs)
if ret_val:
q.put(("Result", ret_val))
return
In ui_gui_qt.py
for _ in range(attempts):
# This will change based on the interface
ret_val = self.gui_user_input(msg, None)
if target is None or ret_val == "ABORT_FORCE":
q.put(ret_val)
return
ret_val = target(ret_val, **kwargs)
if ret_val:
q.put(("Result", ret_val))
return
example validator target
def _float_validate(entry):
"""Requires float entry"""
try:
return float(entry)
except ValueError:
user_info("Please enter a number")
return False
The ui implementations of requesting user input have a flaw when returning results. This is due to the validator functions returning a Union of validated input and False . The ui functions then blindly convert the result to a boolean and loop without feedback if a false value is received from the input validator. If a valid input converts to false, then the input is discarded.
I found this happening specifically with
user_input_float
as 0 or 0.0 are valid floats.In
cmd_line.py
In
ui_gui_qt.py
example validator target