Conversation
There was a problem hiding this comment.
Pull request overview
Updates the climate cache reset utility to safely no-op when no ClimateSimulation instance is available (i.e., None), avoiding crashes when callers attempt to reset a missing simulation.
Changes:
- Broaden
reset_climate_cacheto acceptOptional[ClimateSimulation]and return early onNone. - Add
Optionaltyping import inclimate.py. - Minor formatting-only change at end of
tests/unit/test_misc.py.
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/openbes/simulations/climate.py |
Allows reset_climate_cache to be called with None by adding an early-return guard and updating type hints/imports. |
tests/unit/test_misc.py |
No functional change; adjusts the file’s final lines formatting. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -1724,6 +1724,8 @@ def reset_climate_cache(climate_sim: ClimateSimulation) -> None: | |||
| climate_sim: The ClimateSimulation instance to reset | |||
There was a problem hiding this comment.
The function now accepts Optional[ClimateSimulation] and returns early on None, but the docstring/Args section still states climate_sim is a ClimateSimulation instance. Please update the parameter documentation to reflect that None is allowed and that the function is a no-op in that case.
| climate_sim: The ClimateSimulation instance to reset | |
| climate_sim: The ClimateSimulation instance to reset, or ``None``. | |
| If ``None`` is passed, the function is a no-op and returns immediately. |
| # Clear the static cache (will be rebuilt on next access if needed) | ||
| if climate_sim is None: | ||
| return |
There was a problem hiding this comment.
New behavior: reset_climate_cache(None) now returns without error. Please add a unit test covering the None input to prevent regressions (and to document the intended no-op semantics).
No description provided.