Skip to content

Conversation

@mscolnick
Copy link
Contributor

@mscolnick mscolnick commented Nov 24, 2025

Summary

Fixes #7265

When a class had a class variable (like A: int = 1) and that variable was referenced within the class scope (e.g., in method default parameters or other class variable definitions), marimo incorrectly concluded the class definition could not be reused. This was because A was being treated as an external dependency rather than a class-scoped variable.

…l dependencies (#7265)

## Summary

Fixes #7265

When a class had a class variable (like `A: int = 1`) and that variable was referenced within the class scope (e.g., in method default parameters or other class variable definitions), marimo incorrectly concluded the class definition could not be reused. This was because `A` was being treated as an external dependency rather than a class-scoped variable.
@vercel
Copy link

vercel bot commented Nov 24, 2025

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

Project Deployment Preview Comments Updated (UTC)
marimo-docs Ready Ready Preview Comment Nov 24, 2025 2:30pm
Copy link

@cursor cursor bot 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 the final PR Bugbot will review for you during this billing cycle

Your free Bugbot reviews will reset on December 22

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

unbounded_refs |= data.required_refs - class_def
# Add the variable to class_def so that later references
# to it don't create unbounded refs
class_def.add(var)
Copy link

Choose a reason for hiding this comment

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

Bug: Line executed multiple times inside loop

The statement unbounded_refs |= mock_visitor.refs - ignore_refs is executed inside the outer for var in mock_visitor.variable_data: loop, causing it to run once per class variable instead of once total. This incorrectly adds mock_visitor.refs - ignore_refs to unbounded_refs multiple times. The line needs to be moved outside the outer loop to execute only after all variables have been processed.

Fix in Cursor Fix in Web

Copy link
Collaborator

@dmadisetti dmadisetti 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 great, way simpler than I thought. Kudos!

@mscolnick mscolnick merged commit 3bc4d8d into main Nov 24, 2025
44 of 60 checks passed
@mscolnick mscolnick deleted the ms/class-variable branch November 24, 2025 17:46
@mscolnick mscolnick added the bug Something isn't working label Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

3 participants