Skip to content

Conversation

@eslteacher902010
Copy link

@eslteacher902010 eslteacher902010 commented Jun 27, 2025

This PR improves test coverage and clarity for three utility functions:

pluralize: Updated signature to take both a count and singular word, defaulting to appending "s" when appropriate.

parse_requires: Added tests to validate parsing of multiline requirement strings.

is_dir_writable: Added cross-platform tests for directory writability, including permission errors and missing directories.

These changes fix test mismatches, improve clarity, and increase overall reliability of Poetry’s helper functions.

@sourcery-ai
Copy link

sourcery-ai bot commented Jun 27, 2025

Reviewer's Guide

Refactors the pluralize helper to use a clear (count, singular) signature with logic to append “s” for non-unit counts and updates tests accordingly to resolve existing failures.

File-Level Changes

Change Details Files
Refactor pluralize signature and logic
  • Changed function signature to accept (count, singular)
  • Updated branching to return singular when count == 1 and append “s” otherwise
  • Preserved behavior when singular is an empty string
poetry/utils/helpers.py
Add and adjust tests for new signature
  • Imported pluralize into test_helpers
  • Added test_pluralize with assertions for counts 0, 1, 2, and empty singular
tests/utils/test_helpers.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @eslteacher902010 - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Member

@radoering radoering left a comment

Choose a reason for hiding this comment

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

I did not even know that such a function exists. 😅

Can you please use pytest.mark.parametrize instead of calling the function multiple times in the test.

And please take a look at the failing pre-commit.ci. See also https://python-poetry.org/docs/contributing/#local-development

@eslteacher902010
Copy link
Author

I did not even know that such a function exists. 😅

Can you please use pytest.mark.parametrize instead of calling the function multiple times in the test.

And please take a look at the failing pre-commit.ci. See also https://python-poetry.org/docs/contributing/#local-development

Thanks for the feedback! I removed the obsolete test_shell.py (now that I understand the shell logic lives in a plugin) and added a test file for the helper functions (pluralize, is_dir_writable, and parse_requires). I also updated the tests to use pytest.mark.parametrize where appropriate. Let me know if there’s anything else I should tweak!

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