Skip to content

Handle already singular compound leaders - #265

Open
deepakganesh78 wants to merge 1 commit into
jaraco:mainfrom
deepakganesh78:fix/issue222-long-compound-singular
Open

Handle already singular compound leaders#265
deepakganesh78 wants to merge 1 commit into
jaraco:mainfrom
deepakganesh78:fix/issue222-long-compound-singular

Conversation

@deepakganesh78

Copy link
Copy Markdown

Fixes #222.

_handle_long_compounds passed the result of singularizing the leading noun directly into str.join. When that noun was already singular, _sinoun returned False, causing singular_noun("pair of scissors") to raise a TypeError.

This uses the original candidate whenever the inflection result is not a string. The plural path is unchanged because _plnoun returns strings, while already-singular compound leaders now remain intact. A regression test and towncrier fragment are included.

Validation:

  • python -m pytest -q — 216 passed, 16 xfailed
  • tests/test_compounds.py — 10 passed
  • mypy reports no error on the changed compound logic; the remaining three errors in inflect/__init__.py are pre-existing

Fall back to the original leading noun when singularization returns a boolean, preventing non-string values from reaching the compound join.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

p.singular_noun("pair_of_scissors") raises a TypeError

1 participant