Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from
Jan 6, 2025

Conversation

mscolnick
Copy link
Contributor

@mscolnick mscolnick commented Jan 4, 2025

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

Copy link

vercel bot commented Jan 4, 2025

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
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

akshayka
akshayka previously approved these changes Jan 6, 2025
Copy link
Contributor

@akshayka akshayka left a comment

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
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.

Copy link

github-actions bot commented Jan 6, 2025

🚀 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