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

[23.7.x backport] Fix key sorting for json.dumps in conda config (#13076) #13088

Merged
merged 2 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion conda/cli/main_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ def execute_config(args, parser):
if context.json:
stdout_write(
json.dumps(
context.collect_all(),
{
str(source): values
for source, values in context.collect_all().items()
},
sort_keys=True,
indent=2,
separators=(",", ": "),
Expand Down
19 changes: 19 additions & 0 deletions news/13076-json-sort-pathlib
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* <news item>

### Bug fixes

* Fix sorting error for `conda config --show-sources --json`. (#13076)

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* <news item>
8 changes: 8 additions & 0 deletions tests/cli/test_main_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,11 @@ def test_config_get_missing(
assert Path(parsed["rc_path"]) == path
assert parsed["success"]
assert "warnings" in parsed


def test_config_show_sources_json(conda_cli: CondaCLIFixture):
stdout, stderr, err = conda_cli("config", "--show-sources", "--json")
parsed = json.loads(stdout.strip())
assert "error" not in parsed # not an error rendered as a json
assert not stderr
assert not err
Loading