Skip to content

Commit

Permalink
refactor: Sort keys when dumping JSON from the command line
Browse files Browse the repository at this point in the history
Issue-310: #310
  • Loading branch information
pawamoy committed Aug 14, 2024
1 parent f89050c commit 8cdffe9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/_griffe/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,10 +410,10 @@ def dump(
started = datetime.now(tz=timezone.utc)
if per_package_output:
for package_name, data in data_packages.items():
serialized = data.as_json(indent=2, full=full)
serialized = data.as_json(indent=2, full=full, sort_keys=True)
_print_data(serialized, output.format(package=package_name)) # type: ignore[union-attr]
else:
serialized = json.dumps(data_packages, cls=JSONEncoder, indent=2, full=full)
serialized = json.dumps(data_packages, cls=JSONEncoder, indent=2, full=full, sort_keys=True)
_print_data(serialized, output)
elapsed = datetime.now(tz=timezone.utc) - started

Expand Down

0 comments on commit 8cdffe9

Please sign in to comment.