diff --git a/plugins/ui/src/deephaven/ui/_internal/utils.py b/plugins/ui/src/deephaven/ui/_internal/utils.py index f31d57a6e..33048a053 100644 --- a/plugins/ui/src/deephaven/ui/_internal/utils.py +++ b/plugins/ui/src/deephaven/ui/_internal/utils.py @@ -37,6 +37,19 @@ } +def is_nullish(value: Any) -> bool: + """ + Check if a value is None or Undefined. + + Args: + value: The value to check. + + Returns: + Whether the value is nullish. + """ + return value is None or value is UNDEFINED + + def get_component_name(component: Any) -> str: """ Get the name of the component @@ -639,11 +652,11 @@ def convert_date_props( The converted props. """ for key in simple_date_props: - if props.get(key) is not UNDEFINED: + if not is_nullish(props.get(key)): props[key] = _convert_to_java_date(props[key]) for key in date_range_props: - if props.get(key) is not UNDEFINED: + if not is_nullish(props.get(key)): props[key] = convert_date_range(props[key], _convert_to_java_date) # the simple props must be converted before this to simplify the callable conversion @@ -660,18 +673,18 @@ def convert_date_props( # now that the converter is set, we can convert simple props to strings for key in simple_date_props: - if props.get(key) is not UNDEFINED: + if not is_nullish(props.get(key)): props[key] = str(props[key]) # and convert the date range props to strings for key in date_range_props: - if props.get(key) is not UNDEFINED: + if not is_nullish(props.get(key)): props[key] = convert_date_range(props[key], str) # wrap the date callable with the convert # if there are date range props, we need to convert as a date range for key in callable_date_props: - if props.get(key) is not UNDEFINED: + if not is_nullish(props.get(key)): if not callable(props[key]): raise TypeError(f"{key} must be a callable") if len(date_range_props) > 0: @@ -703,7 +716,7 @@ def convert_time_props( The converted props. """ for key in simple_time_props: - if props.get(key) is not None: + if not is_nullish(props.get(key)): props[key] = _convert_to_java_time(props[key]) # the simple props must be converted before this to simplify the callable conversion @@ -711,12 +724,12 @@ def convert_time_props( # now that the converter is set, we can convert simple props to strings for key in simple_time_props: - if props.get(key) is not None: + if not is_nullish(props.get(key)): props[key] = str(props[key]) # wrap the date callable with the convert for key in callable_time_props: - if props.get(key) is not None: + if not is_nullish(props.get(key)): if not callable(props[key]): raise TypeError(f"{key} must be a callable") props[key] = _wrap_time_callable(props[key], converter) diff --git a/plugins/ui/src/deephaven/ui/components/stack.py b/plugins/ui/src/deephaven/ui/components/stack.py index 3a2745c21..bc7556bae 100644 --- a/plugins/ui/src/deephaven/ui/components/stack.py +++ b/plugins/ui/src/deephaven/ui/components/stack.py @@ -10,7 +10,7 @@ def stack( *children: Any, height: float | Undefined = UNDEFINED, width: float | Undefined = UNDEFINED, - activeItemIndex: int | Undefined = UNDEFINED, + active_item_index: int | Undefined = UNDEFINED, key: str | Undefined = UNDEFINED, **kwargs: Any, ) -> Element: