Add pluralize utility with unit tests - #1682
Open
Copilot wants to merge 2 commits into
Open
Conversation
Extract duplicated pluralization logic from bowtie/_cli.py into a small, reusable bowtie._utils.pluralize helper, and cover it with unit tests and doctests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a small, reusable
pluralizeutility tobowtie/_utils.pyand covers it with unit tests + doctests.Bowtie's CLI (
bowtie/_cli.py) had duplicated inline pluralization logic in two places:This extracts that into
bowtie._utils.pluralize(count, noun, plural=None)and updates both call sites to use it.Changes
bowtie/_utils.py(new):pluralizehelper with doctestsbowtie/_cli.py: refactor both duplicated pluralization call sites to use the new helpertests/test_utils.py(new): unit tests covering singular, plural, zero, negative counts, and custom plural formsValidation
pytest tests/test_utils.py- 6 passedpython -m doctest bowtie/_utils.py- all doctests passedruff checkon changed files - all checks passed