Skip to content

Avoid a serial comma when joining only two items - #84

Open
oyeong011 wants to merge 1 commit into
xolox:masterfrom
oyeong011:fix/serial-comma-two-items
Open

Avoid a serial comma when joining only two items#84
oyeong011 wants to merge 1 commit into
xolox:masterfrom
oyeong011:fix/serial-comma-two-items

Conversation

@oyeong011

Copy link
Copy Markdown

Fixes #63.

concatenate(['foo', 'bar'], serial_comma=True) currently returns foo, and bar. A serial comma applies to lists of three or more items. Check the remaining item count after popping the final item, so two-item lists produce foo and bar.

Regression checks cover empty, single-item, two-item, three-item, custom-conjunction, and iterator inputs.

Validation: the affected text tests pass, flake8 passes, and real API checks pass with up to 10,000 items. Running all tests in isolated processes on Python 3.11/macOS gives 67 passes and two timeouts (test_generate_warning, test_terminal_capabilities); the unmodified base gives the identical result. The standard captured pytest run is also blocked by these existing capture interactions. Historical Python versions were not tested.

AI disclosure: this patch and its tests were prepared with OpenAI Codex and verified by executing the tests and public APIs.

A serial comma separates the penultimate item only in lists of at least three items. Check the remaining count after popping the final item.

Confidence: high
Scope-risk: narrow
Tested: 67 isolated tests pass; affected text tests and large generator API calls pass; flake8 passes
Not-tested: Two pre-existing macOS capture tests time out identically on baseline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

concatenate - serial comma incorrectly used with two items

1 participant