Skip to content

Fix mutable default arguments in sensor_analysis and clearsky_analysis#489

Closed
Copilot wants to merge 2 commits intodevelopmentfrom
copilot/sub-pr-487
Closed

Fix mutable default arguments in sensor_analysis and clearsky_analysis#489
Copilot wants to merge 2 commits intodevelopmentfrom
copilot/sub-pr-487

Conversation

Copy link
Contributor

Copilot AI commented Mar 5, 2026

sensor_analysis and clearsky_analysis used mutable default arguments (analyses=[...], yoy_kwargs={...}, srr_kwargs={}), risking state leakage between calls if those objects were mutated.

Changes

  • Replaced mutable defaults with None in both sensor_analysis and clearsky_analysis
  • Initialize actual defaults (["yoy_degradation"], {"label": "right"}, {}) inside the method body
# Before
def sensor_analysis(self, analyses=["yoy_degradation"], yoy_kwargs={"label": "right"}, srr_kwargs={}):
    ...

# After
def sensor_analysis(self, analyses=None, yoy_kwargs=None, srr_kwargs=None):
    if analyses is None:
        analyses = ["yoy_degradation"]
    if yoy_kwargs is None:
        yoy_kwargs = {"label": "right"}
    if srr_kwargs is None:
        srr_kwargs = {}
    ...

Same pattern applied to clearsky_analysis.

Checklist

  • Code changes are covered by tests
  • Code changes have been evaluated for compatibility/integration with TrendAnalysis
  • New functions added to __init__.py
  • API.rst is up to date, along with other sphinx docs pages
  • Example notebooks are rerun and differences in results scrutinized
  • Updated changelog

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI mentioned this pull request Mar 5, 2026
6 tasks
Co-authored-by: cdeline <23244088+cdeline@users.noreply.github.com>
Copilot AI changed the title [WIP] Work in progress to address feedback from review on release 3.2.0 Fix mutable default arguments in sensor_analysis and clearsky_analysis Mar 5, 2026
@codecov-commenter
Copy link

codecov-commenter commented Mar 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.92%. Comparing base (1476f02) to head (f4f84ce).
⚠️ Report is 2 commits behind head on development.

Additional details and impacted files
@@               Coverage Diff               @@
##           development     #489      +/-   ##
===============================================
+ Coverage        96.90%   96.92%   +0.01%     
===============================================
  Files               12       12              
  Lines             2328     2341      +13     
===============================================
+ Hits              2256     2269      +13     
  Misses              72       72              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@cdeline
Copy link
Collaborator

cdeline commented Mar 6, 2026

I dont like these proposed changes. The 'issue' that is solved is not really an issue because our mutable types that gets passed in like the 'yoy_kwargs' dict is only ever read, never written or updated. And the downside is that the proposed change moves important default behavior deeper into the function and makes it harder to trace the logic and document how to interact with the TA object for the user. Canceling this PR.

@cdeline cdeline closed this Mar 6, 2026
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.

3 participants