Skip to content

Commit

Permalink
Fix sorting case sensitivity in list command (pdm-project#1973)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbalabka authored Jun 4, 2023
1 parent 1209a0b commit a236502
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/pdm/cli/commands/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def _group_of(name: str) -> set[str]:
keys = parse_comma_separated_string(options.sort)
if not all(key in Listable.KEYS for key in keys):
raise PdmUsageError(f"--sort key must be one of: {','.join(Listable.KEYS)}")
records.sort(key=lambda d: tuple(d[key] for key in keys))
records.sort(key=lambda d: tuple(d[key].lower() for key in keys))

# Write CSV
if options.csv:
Expand Down
3 changes: 2 additions & 1 deletion tests/cli/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def test_list_bare(project, pdm):
@mock.patch("pdm.termui.ROUNDED", ASCII)
@pytest.mark.usefixtures("working_set")
def test_list_bare_sorted_name(project, pdm):
pdm(["add", "requests"], obj=project, strict=True)
pdm(["add", "requests", "PyYAML"], obj=project, strict=True)
result = pdm(["list", "--sort", "name"], obj=project)
expected = (
"+--------------------------------------+\n"
Expand All @@ -439,6 +439,7 @@ def test_list_bare_sorted_name(project, pdm):
"| certifi | 2018.11.17 | |\n"
"| chardet | 3.0.4 | |\n"
"| idna | 2.7 | |\n"
"| PyYAML | 6.0 | |\n"
"| requests | 2.19.1 | |\n"
"| test-project | 0.0.0 | |\n"
"| urllib3 | 1.22 | |\n"
Expand Down
3 changes: 2 additions & 1 deletion tests/fixtures/pypi.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@
"1.0": {
"dependencies": ["django<2"]
}
}
},
"PyYAML": { "6.0": {} }
}

0 comments on commit a236502

Please sign in to comment.