Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: pretty-print JSON in snapshots #647

Merged
merged 4 commits into from
Jul 31, 2024

Conversation

willmurphyscode
Copy link
Contributor

@willmurphyscode willmurphyscode commented Jul 30, 2024

Otherwise, it can be very hard to review a PR that updates a snapshot.

For some added context, #645 shows some differences in snapshot JSON that look like they're just reordering keys, but it's very hard to tell. Therefore, sort and indent the JSON on snapshot comparison so that the diffs are more obvious.

This was discovered on the way to fixing #644.

Note for reviewers: there are only a few manual changes in this PR:

  • the script at scripts/format-json-snapshots.py is added
  • It is invoked in during make format via the makefile change
  • tests/conftext.py is changed to format json before comparing workspace snapshots
  • all the changes to the snapshots themselves were made by running make format

Otherwise, it can be very hard to review a PR that updates a snapshot.

Signed-off-by: Will Murphy <[email protected]>
@willmurphyscode willmurphyscode self-assigned this Jul 30, 2024
orjson is the preferred JSON package in this project, but only supports
indent 2. Track the script that formats the JSON snapshots, and switch
to indenting at 2 spaces to permit using orjson.

Signed-off-by: Will Murphy <[email protected]>
Signed-off-by: Will Murphy <[email protected]>
Since this script is not part of Vunnel, it should not be declared in
the pyproject.toml tool.poetry.scripts block.

Signed-off-by: Will Murphy <[email protected]>
@willmurphyscode willmurphyscode merged commit db736b8 into main Jul 31, 2024
12 checks passed
@willmurphyscode willmurphyscode deleted the chore-pretty-print-snapshots branch July 31, 2024 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants