fix(convert): AST-based __main__ guard (salvage of #10237, credit @vidigoat)#10284
Closed
Bartok9 wants to merge 1 commit into
Closed
fix(convert): AST-based __main__ guard (salvage of #10237, credit @vidigoat)#10284Bartok9 wants to merge 1 commit into
Bartok9 wants to merge 1 commit into
Conversation
Avoids mangling cells when the guard text appears inside a string or comment. Also handles single-quoted and reversed comparisons. Based on work by @vidigoat in marimo-team#10237. Co-authored-by: Vidit Patankar <vidit.patankar16@gmail.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
2 tasks
Contributor
Author
|
I have read the CLA Document and I hereby sign the CLA |
Member
|
I think @vidigoat is actively working on this- could you hold off "salvaging". Please remember this for other contributors and at least ask first. |
Contributor
Author
|
Absolutely — apologies for jumping in, @dmadisetti. @vidigoat should own this; I'll close this out so #10237 has a clear path. I'll ask first before picking up in-progress work going forward. Thanks for the nudge, and sorry for the noise. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request was authored by a coding agent.
AI-assisted; human-reviewed line-by-line.
Summary
marimo convert(and related non-marimo script paths) used a naive string split onif __name__ == "__main__":. When that text appeared inside a string literal or comment, the cell was sliced mid-token and emitted as an unparsable blob.This salvage rebases and re-lands @vidigoat's approach from #10237: detect a real top-level
ast.Ifmain-guard and rewrite only that statement. Also covers single-quoted and reversed comparisons.Salvage of #10237 — full credit to @vidigoat.
Tests
Checklist