Open AdrienDart opened 1 month ago
Hmm, I don't think the formatting got preserved in your reporting. Do you mean something like:
with mo.persistent_cache("test"):
a = (b
)
Under the hood, persistent cache attempts to extract the code block, so there might be something brittle there
tip use 3 backticks for formatting
```python
print("hello world")
Apologies, I'm typing this on my phone.
This works:
with mo.persistent_cache("test"):
a = (b
)
This doesn't work (and the formatter formats the code like this):
with mo.persistent_cache("test"):
a = (
b
)
Got it. Thanks for reporting
Example notebook:
Additional context from @dmadisetti:
It's an AST issue to determine where the block starts, we look for the first expression, and check to make sure it isn't in a for or try block, since that behavior would be undefined:
Describe the bug
When persistent caching a cell, I got the following error: AssertionError('Unexpected block') when the cell is formatted as follow (and the formatter gives this format when a is a bit chunk of code: " b = ( a )
Environment
0.9.9
Code to reproduce
`import polars as pl import marimo as mo
a=pl.DataFrame({a=[1]})`
New cell with mo.persistent_cache("my_cache"): (Indent) b = ( a )
If b = (a ), there is no issue