-
Notifications
You must be signed in to change notification settings - Fork 749
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
When enabling Format on save in the Editor-Formatting user settings, this will convert SQL cells to python code for formatting, but keeping them a SQL cell. So next formatting will convert again to python, having a cascaded, not functional cell like:
result = mo.sql(
f"""
result = mo.sql(
f\"""
SELECT
*
FROM OBFUSCATED
\""",
engine=engine,
)
""",
engine=engine
)This is not the case for oneliners I have (I suspect, bc. they do not need formatting).
Will you submit a PR?
- Yes
Environment
{
"marimo": "0.17.0",
"editable": false,
"location": "OBFUSCATED",
"OS": "Windows",
"OS Version": "11",
"Processor": "Intel64 Family 6 Model 140 Stepping 1, GenuineIntel",
"Python Version": "3.13.9",
"Locale": "de_DE",
"Binaries": {
"Browser": "--",
"Node": "v22.20.0"
},
"Dependencies": {
"click": "8.3.0",
"docutils": "0.22.2",
"itsdangerous": "2.2.0",
"jedi": "0.19.2",
"markdown": "3.9",
"narwhals": "2.9.0",
"packaging": "25.0",
"psutil": "7.1.1",
"pygments": "2.19.2",
"pymdown-extensions": "10.16.1",
"pyyaml": "6.0.3",
"starlette": "0.48.0",
"tomlkit": "0.13.3",
"typing-extensions": "4.15.0",
"uvicorn": "0.38.0",
"websockets": "15.0.1"
},
"Optional Dependencies": {
"altair": "5.5.0",
"duckdb": "1.4.1",
"nbformat": "5.10.4",
"openai": "2.6.0",
"pandas": "2.3.3",
"polars": "1.34.0",
"pyarrow": "21.0.0",
"loro": "1.8.1",
"pytest": "8.4.2",
"python-lsp-server": "1.13.1",
"ruff": "0.14.1",
"sqlglot": "27.28.1"
},
"Experimental Flags": {
"sql_linter": true
}
}
Code to reproduce
- Save code from minimal example below as
reproduction-6882.py - Run marimo in edit mode on file
- Enable
Format on save - Hit save & wait
--> cell will become scrambled
Minimal Example:
import marimo
__generated_with = "0.17.0"
app = marimo.App(width="medium")
@app.cell
def _():
import marimo as mo
import pandas as pd
return mo, pd
@app.cell
def _(pd):
_data = {
"id": range(1, 11),
"value": [x * 1.5 for x in range(1, 11)],
}
df = pd.DataFrame(_data, dtype="str")
return (df,)
@app.cell
def _(df, mo):
_df = mo.sql(
f"""
CREATE OR REPLACE TABLE sample_data AS
SELECT * FROM df
"""
)
return (sample_data,)
@app.cell
def _(df, mo, sample_data):
_df = mo.sql(
f"""
SELECT
id AS idid,
value as valval
FROM
sample_data
WHERE
id IN ({','.join(df['id'][0:2].to_list())})
"""
)
return
if __name__ == "__main__":
app.run()Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working