← Back to issue list

`humanize_list` output is incorrect when list contains only one item

View original Github issue

Metadata

Project
craft-cli
Number
#412
Type
issue
State
closed
Author
lengau
Labels
Status: Triaged Type: Bug
Created
Updated
Closed

Current evaluation

Fixed in merged PR #425 (commit c7a1d2b). humanize_list now returns the sole item for 1-element lists (plus 'a and b' for two items), with new unit tests in tests/unit/test_utils.py.

Resolution: closed resolved

Reason: Maintainer cmatsuoka closed the issue citing PR #425, which merged as commit c7a1d2b 'fix(utils): correct humanize_list for two-item lists'. craft_cli/utils.py now short-circuits len==1 to return values[0], and tests/unit/test_utils.py covers single/two/three-plus item cases.

Evaluated by: mr-cal-bot

No scores available.

Issue body

### Bug Description When `humanize_list` is run with only a single item, it returns an invalid value. ``` >>> craft_cli.utils.humanize_list(['1']) ', and 1' ``` ### To Reproduce ``` craft_cli.utils.humanize_list(['1']) ``` ### part yaml ```shell ``` ### Relevant log output ```shell n/a ```

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Fixed in merged PR #425 (commit c7a1d2b). humanize_list now returns the sole item for 1-element lists (plus 'a and b' for two items), with new unit tests in tests/unit/test_utils.py.
stealth/space-bunny-alpha — closed resolved Resolved by merged PR #425 (c7a1d2b), which added regression tests for single-item lists and corrected humanize_list formatting for two-item lists.
qwen/qwen3.6-35b-a3b — — Fixed in PR #425. The humanize_list function incorrectly formatted single-item lists, but the bug was already resolved on the main branch before implementation.
qwen/qwen3.6-35b-a3b
Staleness: 70
Complexity: 10
Confidence: 90
Support Request: 5
close stale Bug report for humanize_list returning incorrect output for single-item lists. Contributor verified the behavior is already fixed on main, but no maintainer response or backport decision has been made.
qwen3.6-35b-a3b-mtp-q6
Staleness: 45
Complexity: 10
Confidence: 90
Support Request: 0
close stale Bug report for humanize_list returning incorrect output for single-item lists. A contributor verified the issue is already resolved on main with existing tests, awaiting maintainer clarification on backporting.

Update history

Date Change
closed

Related work

  • Likely Fixed By: canonical/craft-cli#425 (confidence 95%)

    Merged PR fixing humanize_list formatting; commit c7a1d2b added the len==1 early return in craft_cli/utils.py and unit tests

Related issues

Issue Project State Summary Similarity
#425 fix(utils): correct humanize_list formatting for two-item lists craft-cli merged Merged: commit c7a1d2b "fix(utils): correct humanize_list for two-item lists (#425)" makes two-item lists render as "a and b" (no serial comma), keeps serial commas for longer lists, and adds unit tests.
72%
#414 `humanize_list` does not properly handle two-item lists. craft-cli closed Fixed in canonical/craft-cli#425 (c7a1d2b): two-item lists now render as "a and b", while longer lists retain serial commas.
71%