Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: preserve trailing comments in pure functions, setup cell#7879

Merged
akshayka merged 5 commits intomainfrom
aka/fix-function-definition-parsing-trailing-comments
Jan 17, 2026
Merged

fix: preserve trailing comments in pure functions, setup cell#7879
akshayka merged 5 commits intomainfrom
aka/fix-function-definition-parsing-trailing-comments

Conversation

Copy link
Contributor

akshayka commented Jan 17, 2026 *
edited
Loading

Before this change, trailing comments in pure functions were stripped on load. That meant that a function

@app.function
def f():
# BEGIN YOUR CODE
...
# END YOUR CODE

was incorrectly parsed as

def f():
# BEGIN YOUR CODE
...

Before this change, trailing comments in pure functions were stripped
on load. That meant that a function

```
@app.function
def f():
# BEGIN YOUR CODE
...
# END YOUR CODE
```

was incorrectly parsed as

```
def f():
# BEGIN YOUR CODE
...
```

This change preserves the trailing comment(s).
akshayka requested a review from dmadisetti as a code owner January 17, 2026 01:19
Copy link

vercel bot commented Jan 17, 2026 *
edited
Loading

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
marimo-docs Ready Preview, Comment Jan 17, 2026 4:11am

vercel bot deployed to Preview January 17, 2026 01:19 View deployment
vercel bot deployed to Preview January 17, 2026 01:21 View deployment
dmadisetti added the bug Something isn't working label Jan 17, 2026
dmadisetti reviewed Jan 17, 2026
dmadisetti reviewed Jan 17, 2026
class MyClass:
def method(self):
pass
# trailing class comment
Copy link
Collaborator

dmadisetti Jan 17, 2026

Choose a reason for hiding this comment

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

Good check

dmadisetti reviewed Jan 17, 2026
assert "# comment 2" in notebook.cells[0].code

@staticmethod
def test_function_without_trailing_comment() -> None:
Copy link
Collaborator

dmadisetti Jan 17, 2026

Choose a reason for hiding this comment

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

Think we have other tests for this, but we do need one for setup_cell

akshayka reacted with thumbs up emoji
Copy link
Collaborator

dmadisetti Jan 17, 2026

Choose a reason for hiding this comment

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

Checking comments after return might be unexpected though (especially if we do change extract_from_code)

Copy link
Contributor Author

akshayka Jan 17, 2026

Choose a reason for hiding this comment

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

Added a setup cell test

akshayka force-pushed the aka/fix-function-definition-parsing-trailing-comments branch from 84e49bb to 95e76b9 Compare January 17, 2026 04:08
vercel bot deployed to Preview January 17, 2026 04:09 View deployment
vercel bot deployed to Preview January 17, 2026 04:11 View deployment
akshayka changed the title fix: preserve trailing comments in pure functions fix: preserve trailing comments in pure functions, setup cell Jan 17, 2026
mscolnick approved these changes Jan 17, 2026
akshayka merged commit a69b2e5 into main Jan 17, 2026
46 of 48 checks passed
akshayka deleted the aka/fix-function-definition-parsing-trailing-comments branch January 17, 2026 16:39
Copy link

github-actions bot commented Jan 17, 2026

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

botterYosuke pushed a commit to botterYosuke/marimo that referenced this pull request Jan 18, 2026
mscolnick pushed a commit that referenced this pull request Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

dmadisetti dmadisetti left review comments

mscolnick mscolnick approved these changes

Assignees

No one assigned

Labels

bug Something isn't working

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants