Skip to content

Commit

Permalink
fix: preserve dictionaries in unwrap_py_scalar
Browse files Browse the repository at this point in the history
Co-Authored-By: Myles Scolnick <myles@marimo.io>
  • Loading branch information
devin-ai-integration[bot] and mscolnick committed Jan 16, 2025
1 parent 3197cf2 commit b6c83a6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions marimo/_utils/narwhals_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit b6c83a6

Please sign in to comment.