marimo-team / marimo

A reactive notebook for Python — run reproducible experiments, execute as a script, deploy as an app, and version with git.
https://marimo.io
Apache License 2.0
5.31k stars 155 forks source link

Add str in conversion to stop toml.type from being encoded and breaking markdown mode #1666

Closed dmadisetti closed 1 week ago

dmadisetti commented 1 week ago

📝 Summary

Saving a new markdown file with a user specified default width, causes breakage since tomlkit loads wrapped types as opposed to raw python types. The result of saving or creating a new md notebook gives something like:

---
title: Example
marimo-version: 0.6.22
width: !!python/object/apply:tomlkit.items.String
- !!python/object/apply:tomlkit.items.StringType
  - '"'
- medium
- medium
- !!python/object:tomlkit.items.Trivia
  indent: ''
  comment_ws: ''
  comment: ''
  trail: '

    '
---

Ideally, you might consider casting config loads to be the raw python values.

To replicate, set your default to something that is not "compact". Then do marimo edit example.md (assuming example.md doesn't exist). Make a change, and try to save. View the raw file.

🔍 Description of Changes

Just run str on frontmatter inputs, this is safer, even if the toml config is properly converted.

📜 Reviewers

@akshayka OR @mscolnick

vercel[bot] commented 1 week ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
marimo-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 24, 2024 4:07am
marimo-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 24, 2024 4:07am
dmadisetti commented 1 week ago

for reference: https://github.com/python-poetry/tomlkit/issues/43

github-actions[bot] commented 1 week ago

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.6.23-dev1