Skip to content

Fix requirements using locals of a top-level modular scenario#455

Merged
dfremont merged 1 commit intomainfrom
fix_requirements
Apr 16, 2026
Merged

Fix requirements using locals of a top-level modular scenario#455
dfremont merged 1 commit intomainfrom
fix_requirements

Conversation

@dfremont
Copy link
Copy Markdown
Collaborator

Description

Fixes #392, wherein an internal error resulted when a require statement in a modular scenario referred to one of the scenario's local variables. The bug actually only happened when the modular scenario was at the top level, not invoked in the compose block of another scenario, but I've added tests for both cases.

Issue Link

Fixes #392.

Checklist

  • I have tested the changes locally via pytest and/or other means
  • I have added or updated relevant documentation
  • I have autoformatted the code with black and isort
  • I have added test cases (if applicable)

Additional Notes

This PR only fixes the specific issue in #392, but I think same kind of issue will happen when other kinds of mutable objects are used inside requirements, e.g. dicts. I'm not sure how to fix the problem in all cases, so I will leave it for a future PR.

@dfremont dfremont requested review from Eric-Vin and lola831 April 15, 2026 20:31
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.73%. Comparing base (3c5102e) to head (b897b05).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #455      +/-   ##
==========================================
+ Coverage   89.71%   89.73%   +0.02%     
==========================================
  Files          48       48              
  Lines       13194    13211      +17     
==========================================
+ Hits        11837    11855      +18     
+ Misses       1357     1356       -1     
Files with missing lines Coverage Δ
src/scenic/core/dynamics/scenarios.py 94.79% <100.00%> (+0.19%) ⬆️
src/scenic/core/requirements.py 96.02% <100.00%> (+0.03%) ⬆️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dfremont dfremont merged commit 8801a3b into main Apr 16, 2026
35 checks passed
@dfremont dfremont deleted the fix_requirements branch April 16, 2026 19:49
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.

Error using local variable in a requirement inside a setup block

2 participants