Skip to content

Release/0.5.0#8

Merged
Qrashi merged 7 commits into
mainfrom
release/0.5.0
Jan 12, 2026
Merged

Release/0.5.0#8
Qrashi merged 7 commits into
mainfrom
release/0.5.0

Conversation

@Qrashi

@Qrashi Qrashi commented Jan 12, 2026

Copy link
Copy Markdown
Collaborator

Add JSONFile.restore_default

  • fix many default handling bugs when used with or without strict
  • changed default for strict to be False
  • rename parameter recover to strict and expand documentation
  • add small tip to documentation

* Fix default handling to make it more precise
* Update tests
* BREAKING: rename recover to strict
* remove deprecated save_atomic
* Add parameter checks to default_data
* Update valid parameters to default_data
* next: update docs
* Edit docstrings to explain strict more
* explain strict more
* add section for importlib.resources.file in defaults.rst
@Qrashi Qrashi requested review from Copilot and removed request for Copilot January 12, 2026 21:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 introduces a new restore_default() method and refactors error handling by renaming the recover parameter to strict with inverted semantics. The default behavior also changes from strict=True to strict=False for both __init__ and the load() function.

Changes:

  • Added a public restore_default(strict: bool) method to explicitly restore files to their default state
  • Renamed recover parameter to strict with inverted logic (recover=True → strict=False) across reload() and initialization
  • Changed default value from strict=True to strict=False making the library more lenient by default
  • Enhanced default data validation with better error messages and handling
  • Removed deprecated save_atomic() method
  • Updated type aliases to distinguish between JSON fields and top-level JSON documents
  • Reduced test timeouts from 2.0s to 0.5s for faster test execution

Reviewed changes

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

Show a summary per file
File Description
src/singlejson/fileutils.py Core changes: added restore_default() method, renamed recover→strict parameter, enhanced validation logic, removed save_atomic(), updated type aliases
src/singlejson/pool.py Updated load() function signature to use strict=False default and improved documentation
tests/test_thread_safety.py Updated test calls from recover=True to strict=True to match new parameter name
tests/test_singlejson.py Added tests for error handling with non-JSON-serializable defaults
tests/test_reload_strict_recover.py Updated all test calls to use strict parameter instead of recover
tests/test_features.py Removed test_save_atomic test for deleted deprecated method
tests/test_defaults.py Added comprehensive tests for strict mode validation and restore_default functionality
tests/test_atomic_save_and_race.py Reduced test timeouts from 2.0s to 0.5s
tests/test_atomic_save.py Removed entire file testing deprecated save_atomic method
docs/source/error_handling.rst Major documentation rewrite explaining strict vs non-strict modes
docs/source/defaults.rst Added tip about using importlib.resources with default_data

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

Comment thread tests/test_reload_strict_recover.py Outdated
Comment thread tests/test_reload_strict_recover.py Outdated
Comment thread tests/test_singlejson.py
Comment thread tests/test_reload_strict_recover.py Outdated
Comment thread docs/source/error_handling.rst Outdated
Comment thread src/singlejson/fileutils.py Outdated
Comment thread src/singlejson/fileutils.py Outdated
Comment thread tests/test_singlejson.py Outdated
Comment thread src/singlejson/fileutils.py Outdated
Comment thread tests/test_reload_strict_recover.py Outdated
* Fix typos in docstrings
* Clear up documentation
* Fix default for reload()
* Add text to documentation for strict=True verification behavior
* Update test comments
* Revert time based tests to 2 seconds
* Remove outdated tests

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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


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

Comment thread tests/test_reload_strict_recover.py Outdated
Comment thread docs/source/error_handling.rst Outdated
Comment thread src/singlejson/fileutils.py Outdated
* Fix typos in error_handling.rst
* Fix wrong indent on test_reload_strict_recover.py
@Qrashi Qrashi merged commit b4dbc74 into main Jan 12, 2026
2 checks passed
@Qrashi Qrashi deleted the release/0.5.0 branch January 12, 2026 23:30
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