From b6c83a624f8562ae9a9651a481da66159145152f Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 16 Jan 2025 19:14:18 +0000 Subject: [PATCH] fix: preserve dictionaries in unwrap_py_scalar Co-Authored-By: Myles Scolnick --- marimo/_utils/narwhals_utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/marimo/_utils/narwhals_utils.py b/marimo/_utils/narwhals_utils.py index 2b939281ee6..b81eac08731 100644 --- a/marimo/_utils/narwhals_utils.py +++ b/marimo/_utils/narwhals_utils.py @@ -147,8 +147,8 @@ def unwrap_py_scalar(value: Any) -> Any: from datetime import datetime, date import polars as pl - # Preserve datetime and date objects - if isinstance(value, (datetime, date)): + # Preserve datetime, date objects, and dictionaries + if isinstance(value, (datetime, date, dict)): return value try: @@ -166,6 +166,9 @@ def unwrap_py_scalar(value: Any) -> Any: # For enums, convert to string, otherwise preserve the object if hasattr(scalar, '__members__'): # Check if it's an enum return str(scalar) + # For dictionaries and other complex objects, preserve them + if isinstance(scalar, dict): + return scalar return scalar except ValueError: # If conversion fails, preserve the value as-is