Skip to content

Comments

Canonicalize dependency group name#852

Closed
finswimmer wants to merge 6 commits intopython-poetry:mainfrom
finswimmer:canonicalize-dependency-group-name
Closed

Canonicalize dependency group name#852
finswimmer wants to merge 6 commits intopython-poetry:mainfrom
finswimmer:canonicalize-dependency-group-name

Conversation

@finswimmer
Copy link
Member

@finswimmer finswimmer commented Mar 15, 2025

Resolves: python-poetry#

  • Added tests for changed code.
  • Updated documentation for changed code.

Summary by Sourcery

Canonicalize dependency group names to ensure consistent handling and add tests to verify the correct behavior.

Enhancements:

  • Canonicalize dependency group names to ensure consistent handling of group names regardless of case or format.

Tests:

  • Add tests to verify that dependency group names are correctly canonicalized and handled in various scenarios.

@sourcery-ai
Copy link

sourcery-ai bot commented Mar 15, 2025

Reviewer's Guide by Sourcery

This pull request implements the canonicalization of dependency group names in the Poetry package management system. The changes ensure that dependency group names are consistently handled in a case-insensitive manner by converting them to a canonical form. This involves updates to the core package logic and the addition of new tests to verify the behavior.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Canonicalize dependency group names in package logic.
  • Updated the has_dependency_group method to use canonicalized names.
  • Modified the dependency_group method to retrieve groups using canonicalized names.
  • Changed the add_dependency method to dynamically add groups using canonicalized names.
  • Updated the without_dependency_groups method to exclude groups using canonicalized names.
  • Modified the with_dependency_groups method to include groups using canonicalized names.
src/poetry/core/packages/package.py
Canonicalize dependency group names in the DependencyGroup class.
  • Set the _name attribute to the canonicalized name.
  • Stored the original name in _original_name.
src/poetry/core/packages/dependency_group.py
Add tests to ensure canonicalization of dependency group names.
  • Added tests to verify that dependency groups are correctly identified using canonicalized names.
  • Added tests to ensure that dependencies are added to the correct canonicalized group.
  • Parameterized tests to check various cases of group name inputs.
tests/packages/test_package.py
tests/packages/test_dependency_group.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!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

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

@finswimmer finswimmer force-pushed the canonicalize-dependency-group-name branch from 7ee33b3 to 075c156 Compare March 28, 2025 12:34
Introduce CanonicalizedDict, a specialized dictionary that canonicalizes string keys for consistency. This includes its implementation in `helpers.py` and corresponding unit tests in `test_helpers.py` to ensure correct behavior for insertion, retrieval, updating, and deletion of keys.
@finswimmer finswimmer force-pushed the canonicalize-dependency-group-name branch from 075c156 to 95286d0 Compare March 30, 2025 11:37
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.

1 participant