Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: poc pep 735 #823

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

finswimmer
Copy link
Member

@finswimmer finswimmer commented Jan 21, 2025

Resolves: python-poetry#

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

Summary by Sourcery

Add support for dependency groups in the package configuration to enhance dependency management flexibility. Update the factory configuration to handle dependency groups and introduce a new test case to ensure proper functionality.

New Features:

  • Introduce support for dependency groups in the package configuration, allowing for more flexible dependency management.

Tests:

  • Add a new test case to verify the creation of poetry projects with dependency groups.

Copy link

sourcery-ai bot commented Jan 21, 2025

Reviewer's Guide by Sourcery

This pull request refactors the package configuration to support dependency groups by introducing a new 'dependency_groups' parameter. It updates the logic to handle these groups and adds a test case along with a sample project fixture to verify the new functionality.

Sequence diagram for dependency group configuration

sequenceDiagram
    participant F as Factory
    participant P as ProjectPackage
    participant DG as DependencyGroup
    participant D as Dependency
    F->>P: configure_package()
    F->>F: _configure_package_dependencies()
    alt Has dependency_groups
        loop For each group
            F->>DG: create(group_name)
            F->>P: add_dependency_group(group)
            loop For each dependency in group
                F->>D: create_from_pep_508(constraint)
                F->>DG: add_dependency(dep)
            end
        end
    end
    alt Has tool_poetry groups
        loop For each group
            F->>DG: create(group_name, optional)
            F->>F: _add_package_group_dependencies()
        end
    end
Loading

Class diagram showing updated Factory class with dependency groups support

classDiagram
    class Factory {
        +configure_package(package, pyproject, root, with_groups)
        -_configure_package_dependencies(package, project, tool_poetry, dependency_groups, with_groups)
        -_add_package_group_dependencies(package, group, dependencies)
    }
    class DependencyGroup {
        +name: string
        +optional: boolean
        +add_dependency(dependency)
    }
    class ProjectPackage {
        +root_dir: string
        +add_dependency_group(group)
    }
    class Dependency {
        +_groups: frozenset
        +create_from_pep_508(constraint, relative_to)
    }
    Factory ..> DependencyGroup: creates
    Factory ..> Dependency: creates
    ProjectPackage o-- DependencyGroup: contains
    DependencyGroup o-- Dependency: contains
    note for Factory "Updated to support PEP 735
dependency groups"
Loading

File-Level Changes

Change Details Files
Refactor package configuration to support dependency groups.
  • Added 'dependency_groups' parameter to 'configure_package' and '_configure_package_dependencies' methods.
  • Modified '_configure_package_dependencies' to handle 'dependency_groups' if provided.
  • Updated logic to add dependencies from 'dependency_groups' to the package.
src/poetry/core/factory.py
Add test for creating poetry with dependency groups.
  • Introduced 'test_create_poetry_with_groups' to test the new dependency groups feature.
tests/test_factory.py
Add sample project fixture with dependency groups for testing.
  • Created 'sample_project_with_groups_new' directory with 'pyproject.toml' and 'README.rst' to serve as a test fixture.
tests/fixtures/sample_project_with_groups_new/pyproject.toml
tests/fixtures/sample_project_with_groups_new/README.rst

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.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a 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. You can also use
    this command to specify where the summary should be inserted.

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

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