suggest bool() for wrong values (#3975)
This commit is contained in:
parent
47c9938d95
commit
a5ad5203df
@ -448,8 +448,16 @@ class Component(BaseComponent, ABC):
|
||||
and not types._issubclass(passed_type, expected_type, value)
|
||||
):
|
||||
value_name = value._js_expr if isinstance(value, Var) else value
|
||||
|
||||
additional_info = (
|
||||
" You can call `.bool()` on the value to convert it to a boolean."
|
||||
if expected_type is bool and isinstance(value, Var)
|
||||
else ""
|
||||
)
|
||||
|
||||
raise TypeError(
|
||||
f"Invalid var passed for prop {type(self).__name__}.{key}, expected type {expected_type}, got value {value_name} of type {passed_type}."
|
||||
+ additional_info
|
||||
)
|
||||
# Check if the key is an event trigger.
|
||||
if key in component_specific_triggers:
|
||||
|
Loading…
Reference in New Issue
Block a user