Skip to content

Conversation

@lewisjared
Copy link
Contributor

@lewisjared lewisjared commented Jan 7, 2026

Description

Resolved warnings about open resources by cleaning up the db

Checklist

Please confirm that this pull request has done the following:

  • Tests added
  • Documentation added (where applicable)
  • Changelog item added to changelog/

@codecov
Copy link

codecov bot commented Jan 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
...ckages/climate-ref/src/climate_ref/cli/__init__.py 97.18% <100.00%> (+0.04%) ⬆️
packages/climate-ref/src/climate_ref/database.py 98.30% <100.00%> (+0.13%) ⬆️
...kages/climate-ref/src/climate_ref/datasets/base.py 98.42% <100.00%> (-0.03%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

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

This PR addresses SQLite resource warnings by properly closing database connections throughout the codebase. The changes introduce context manager support for the Database class and update test fixtures and tests to ensure proper resource cleanup.

Key changes:

  • Added __enter__, __exit__, and close() methods to Database class for context manager support
  • Updated test fixtures to use generators with proper cleanup (db, db_seeded, test_db)
  • Modified CLI to use ctx.with_resource for automatic database cleanup
  • Upgraded pytest (>=9.0.0) and mypy (>=1.19.0) dependencies

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
uv.lock Updated mypy and pytest version constraints to >=1.19.0 and >=9.0.0 respectively
pyproject.toml Updated mypy and pytest versions; changed pytest configuration section name and added strict option
packages/climate-ref/tests/unit/test_database.py Wrapped test using Database.from_config in context manager and added explicit close() calls
packages/climate-ref/tests/unit/executor/test_result_handling.py Added filterwarnings decorators to suppress expected UserWarnings
packages/climate-ref/tests/unit/datasets/test_datasets.py Changed test_db fixture from return to yield with cleanup
packages/climate-ref/tests/unit/datasets/test_cmip6.py Fixed pandas warnings with proper DataFrame copying and deprecated infer_objects parameter usage; wrapped database in context manager
packages/climate-ref/src/climate_ref/datasets/base.py Refactored load_catalog to use transform instead of deprecated apply
packages/climate-ref/src/climate_ref/database.py Added context manager protocol and close() method for proper resource cleanup
packages/climate-ref/src/climate_ref/cli/init.py Used ctx.with_resource to ensure database connection is closed when CLI exits
packages/climate-ref/conftest.py Converted db and db_seeded fixtures to generators with proper cleanup; added database.close() in db_seeded_template
changelog/482.improvement.md Added changelog entry documenting the cleanup of database connections

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@lewisjared lewisjared merged commit f98aa03 into main Jan 8, 2026
13 checks passed
@lewisjared lewisjared deleted the fix-sqllite branch January 8, 2026 08:33
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