Skip to content

Fix pluralize for words ending in z - #586

Open
Debasishhh wants to merge 2 commits into
mahmoud:masterfrom
Debasishhh:pluralize-z
Open

Debasishhh wants to merge 2 commits into
mahmoud:masterfrom
Debasishhh:pluralize-z

Conversation

@Debasishhh

Copy link
Copy Markdown

The change

pluralize() added a bare s to words ending in z:

>>> pluralize('buzz'), pluralize('waltz'), pluralize('quiz')
('buzzs', 'waltzs', 'quizs')

#429 added x to the -es rule but z was missed. This adds z to that rule (buzzes, waltzes, Fizzes), and adds quiz to the irregular plurals so it becomes quizzes (and singularize('quizzes') returns quiz). A general z-doubling rule would be wrong for words like topaz, so quiz is listed explicitly.

The backstory

Follow-up to #585, found during the same read-through.

AI assistance

  • Harness/tooling (Claude Code, Cursor, Codex, etc.): Claude Code
  • Model(s): Claude Opus 5.5 (Sonnet subagents for the issue search)
  • Original prompt(s), as close to verbatim as you can manage:
    • "use this skill to find out repos i can contribute" (a code-reading pass surfaced the pluralize bug)
    • "now do the pluralize fix"

@Wkhanex Wkhanex left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an adjacent singularize gap worth considering alongside the new z plural rule. At b4c338e, the new plurals are correct, but feeding them into the paired helper gives:

singularize(pluralize('buzz'))   # 'buzze'
singularize(pluralize('waltz'))  # 'waltze'
singularize(pluralize('topaz'))  # 'topaze'

The same issue affects fizz and is preserved in title/upper case, while the new irregular quiz entry round-trips correctly. Would it make sense to extend the reverse -zes handling and cover these round trips too? The singularize behavior for these already-plural strings predates this PR; this is an adjacent consistency gap, not a claim that the PR introduced that implementation defect.

I ran an independent expected-word/case matrix and the existing strutils tests on CPython 3.12.14. All 28 existing tests pass; the added round-trip check fails with the results above.

Review prepared with Codex assistance; the checks described above were executed locally.

@Debasishhh

Copy link
Copy Markdown
Author

Yeah singularize is already off for these, boxes gives boxe too. Didn't want to mix it in here though since -zes is ambiguous (buzzes -> buzz but sizes -> size). Can do a separate PR if @mahmoud wants

This branch has not been deployed

No deployments
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.

2 participants