snip source correctly for dep tracker#5613
Conversation
There was a problem hiding this comment.
Greptile Summary
This PR addresses a critical bug in Reflex's dependency tracking system, specifically in how source code snippets are handled during variable analysis. The change modifies the _eval_var method in reflex/vars/dep_tracking.py to correctly extract source code when evaluating variable dependencies.
The fix specifically adjusts the string slicing logic to properly handle multi-line source code snippets. When extracting variable names from source code, it now correctly joins the source lines while preserving the complete variable names, addressing a truncation issue that was causing variables like 'loaded_experiment' to be incorrectly identified as 'loaded_experimen'.
This change is fundamental to Reflex's state management system, ensuring accurate dependency tracking and state variable access through get_var_value.
PR Description Notes:
- The PR description could be more detailed, explaining the problem and solution more thoroughly
Confidence score: 5/5
- This PR is very safe to merge as it fixes a clear bug with a straightforward solution
- The changes are minimal, focused, and the logic correction is evident - improper string slicing is replaced with correct concatenation
- Key files needing attention: reflex/vars/dep_tracking.py
1 file reviewed, no comments
CodSpeed Performance ReportMerging #5613 will not alter performanceComparing Summary
|
masenf
left a comment
There was a problem hiding this comment.
can we get a unit test added for this
the code is a bit weird, but i will try |
fixes #5580