Conversation
# Conflicts: # .github/workflows/ci.yml
# Conflicts: # pyproject.toml # uv.lock
There was a problem hiding this comment.
Pull request overview
This PR migrates the snapshot file format from plain JSON (.json) to gzip-compressed JSON (.json.gz) to improve storage efficiency. This is a breaking change appropriately reflected by bumping the version from 0.5.0 to 0.6.0.
Key changes:
- Updated snapshot read/write functions to use gzip compression and binary file I/O
- Modified all file paths, help text, and documentation to use
.json.gzextension - Updated test suite to handle gzip-compressed snapshots
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/snaplint/snapshot.py |
Added gzip compression to write_snapshot() and decompression to read_snapshot(), changed I/O to binary mode, added gzip.BadGzipFile error handling |
src/snaplint/cli.py |
Updated default snapshot paths to use .json.gz, changed file open modes to binary ('wb'/'rb'), updated help text |
tests/test_cli.py |
Added gzip import, updated snapshot file fixture path, modified snapshot validation to use gzip.open() |
tests/test_e2e.py |
Added gzip import, updated all snapshot file paths to .json.gz, modified snapshot reading to use gzip.open() |
README.md |
Updated documentation to reflect gzip-compressed format and .json.gz extension |
pyproject.toml |
Bumped version from 0.5.0 to 0.6.0 |
uv.lock |
Updated version reference |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| data = json.loads(json_str) | ||
| return SnapshotFile.model_validate(data) | ||
| except gzip.BadGzipFile as e: | ||
| raise SnapshotReadError(f"Invalid gzip file: {e}") from e |
There was a problem hiding this comment.
The error handling should also catch UnicodeDecodeError separately to provide a clearer error message when the gzip file decompresses successfully but contains invalid UTF-8 data. Currently, it would be caught by the generic Exception handler which gives a less specific error message. Consider adding:
except UnicodeDecodeError as e:
raise SnapshotReadError(f"Invalid UTF-8 encoding in snapshot file: {e}") from ebetween the gzip.BadGzipFile and json.JSONDecodeError handlers.
| raise SnapshotReadError(f"Invalid gzip file: {e}") from e | |
| raise SnapshotReadError(f"Invalid gzip file: {e}") from e | |
| except UnicodeDecodeError as e: | |
| raise SnapshotReadError(f"Invalid UTF-8 encoding in snapshot file: {e}") from e |
This pull request updates the snapshot file format in Snaplint from plain JSON to gzip-compressed JSON (
.json.gz). The change affects the CLI, core snapshot logic, documentation, and tests to ensure all snapshot files are handled as compressed files for improved efficiency and compatibility.Snapshot file format migration:
.jsonto.json.gzto indicate gzip compression. This includes default paths, help text, and file handling logic. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14]Snapshot read/write logic:
src/snaplint/snapshot.pynow use gzip compression and decompression, respectively. File I/O is switched to binary mode, and error handling for gzip files is added. [1] [2] [3] [4]Documentation updates:
README.mdis updated to clarify that snapshots are now stored as gzip-compressed JSON files, with all examples and explanations reflecting the new.json.gzextension. [1] [2] [3]Test suite updates:
.json.gzextension. This ensures tests validate the new compressed format. [1] [2] [3] [4] [5] [6]Version bump:
0.5.0to0.6.0inpyproject.tomlto reflect this breaking change.