Repository navigation
chore(config): write predbat_config.json one setting per line - #5422
Merged
Merged
Conversation
The settings file was a single line, so a change to one setting showed as the whole file changing when the file is kept in git or compared. It is now written with json.dump(indent=2) and a trailing newline, in the same CONFIG_ITEMS order as before. It is still plain JSON, so loading is unchanged; a test checks the layout and that the file loads back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The formatting change is covered by regression tests and preserves compatibility.
Review effort: Lite
Findings: None
What changed in this PR
Formats predbat_config.json with readable indentation and a trailing newline while preserving loading behavior.
Changes:
- Writes formatted JSON configuration.
- Adds formatting and round-trip tests.
- Registers the new test.
| File | Description |
|---|---|
apps/predbat/userinterface.py |
Writes formatted configuration JSON. |
apps/predbat/unit_test.py |
Registers the new test. |
apps/predbat/tests/test_config_json_format.py |
Tests formatting and loading. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…test load_current_config() rewrites every saved CONFIG_ITEMS value on the shared PredBat fixture, but the test only put load_scaling back. Any value that does not survive a JSON round-trip unchanged (a tuple read back as a list, for example) would then leak into later tests, the order-dependent pollution seen in #5079. Snapshot all values before the save and restore them in the finally block. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
predbat_config.jsonwas written as a single line, so changing one setting showed as the whole file changing when the file is kept in git or compared between two saves. It is now written withjson.dump(..., indent=2)and a trailing newline: one setting per line, in the sameCONFIG_ITEMSorder as before.It is still plain JSON, so
load_current_config()reads it exactly as before, and an existing single-line file still loads. The first save after upgrading rewrites it in the new layout.Changes
apps/predbat/userinterface.py:save_current_config()indents the JSON and ends the file with a newline.apps/predbat/tests/test_config_json_format.py(new): the saved file is exactlyjson.dumps(settings, indent=2)plus a newline, a setting sits on its own line, the file loads back to the same value, and every setting on the shared test fixture is restored afterwards.apps/predbat/unit_test.py: registers the test.Test plan
./run_all --test config_json_format --test new_install_detection./run_all --quickcoverage/run_pre_commit🤖 Generated with Claude Code