Release/0.5.0#8
Merged
Merged
Conversation
* 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
Contributor
There was a problem hiding this comment.
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
recoverparameter tostrictwith inverted logic (recover=True → strict=False) across reload() and initialization - Changed default value from
strict=Truetostrict=Falsemaking 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.
* 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
Contributor
There was a problem hiding this comment.
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.
* Fix typos in error_handling.rst * Fix wrong indent on test_reload_strict_recover.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add JSONFile.restore_default