Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wusteven815 committed Oct 29, 2024
1 parent 327860a commit 517e9cc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
29 changes: 21 additions & 8 deletions plugins/ui/src/deephaven/ui/_internal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -703,20 +716,20 @@ 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
converter = _prioritized_time_callable_converter(props, priority, default_converter)

# 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)
Expand Down
2 changes: 1 addition & 1 deletion plugins/ui/src/deephaven/ui/components/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 517e9cc

Please sign in to comment.