Skip to content

fix: reset when ClimateSimulation=None#22

Open
mjaquiery wants to merge 64 commits intomainfrom
fix/update
Open

fix: reset when ClimateSimulation=None#22
mjaquiery wants to merge 64 commits intomainfrom
fix/update

Conversation

@mjaquiery
Copy link
Copy Markdown
Member

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_cache to accept Optional[ClimateSimulation] and return early on None.
  • Add Optional typing import in climate.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.

Comment thread src/openbes/simulations/climate.py Outdated
@@ -1724,6 +1724,8 @@ def reset_climate_cache(climate_sim: ClimateSimulation) -> None:
climate_sim: The ClimateSimulation instance to reset
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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.

Copilot uses AI. Check for mistakes.
Comment on lines 1726 to +1728
# Clear the static cache (will be rebuilt on next access if needed)
if climate_sim is None:
return
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

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).

Copilot uses AI. Check for mistakes.
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.

2 participants