Skip to content

feat: add auto-fix for multiple definctions and popular imports#3343

Merged
mscolnick merged 5 commits into
mainfrom
ms/autofix
Jan 6, 2025
Merged

feat: add auto-fix for multiple definctions and popular imports#3343
mscolnick merged 5 commits into
mainfrom
ms/autofix

Conversation

@mscolnick

@mscolnick mscolnick commented Jan 4, 2025

Copy link
Copy Markdown
Contributor

Part of #3110

This adds two autofixes for different marimo errors. This opens the door for more autofixes as well. Right now this happens on all the frontend because 1) the code transformations are not that difficult and 2) still requires frontend logic like focusing the editor or adding a new cell. We could move some of this to the backend but would prefer to put the auto-fixes into a a proper linting framework + LSP.

The autofixes:

  • multiple definitions -> Make this cell's variables local by wrapping the cell in a function.
  • missing name -> Add a new cell for the missing import

image

@vercel

vercel Bot commented Jan 4, 2025

Copy link
Copy Markdown

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 Jan 6, 2025 6:12pm
marimo-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 6, 2025 6:12pm

@mscolnick
mscolnick marked this pull request as draft January 4, 2025 05:07
tf: "import tensorflow as tf",
torch: "import torch",
xr: "import xarray as xr",
};

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could probably consolidate this

Comment thread frontend/src/core/errors/errors.ts Outdated
akshayka
akshayka previously approved these changes Jan 6, 2025

@akshayka akshayka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome! I played with it, and it works well. Just one comment on formatting.

...indentLines(linesBeforeLastStmt, indentation),
`${indentation}return ${linesRest[0]}`,
...indentLines(linesRest.slice(1), indentation),
"_()",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you insert two blank lines before _()? To make it roughly match what ruff format would generate.

@github-actions

github-actions Bot commented Jan 6, 2025

Copy link
Copy Markdown
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants