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

poetry: expose build-system dependencies #319

Merged
merged 1 commit into from
Jan 17, 2025

Conversation

abn
Copy link
Member

@abn abn commented Apr 2, 2022

This change allows for a Poetry project instance's build-system requirements to be accessed as Dependency instances. Preserving useful parsing from #58 as original PR was dropped.

Summary by Sourcery

New Features:

  • Access build-system requirements as Dependency instances.

@abn abn requested a review from a team April 2, 2022 01:41
@abn abn force-pushed the build-system-requires branch from 1386faf to 99e8da4 Compare April 27, 2022 01:05
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
1.6% 1.6% Duplication

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@neersighted neersighted added this to the 1.2 milestone Aug 26, 2022
@neersighted neersighted modified the milestones: 1.2, 1.3 Sep 17, 2022
@abn abn force-pushed the build-system-requires branch from 2ae4888 to 7bd850e Compare January 12, 2025 23:58
@abn abn requested review from Secrus and a team and removed request for a team January 12, 2025 23:58
@abn
Copy link
Member Author

abn commented Jan 12, 2025

@sourcery-ai review

Copy link

sourcery-ai bot commented Jan 12, 2025

Reviewer's Guide by Sourcery

This pull request exposes the build-system dependencies of a Poetry project as Dependency instances. This allows for easier access and manipulation of these dependencies.

Sequence diagram for build system dependency resolution

sequenceDiagram
    participant Poetry
    participant PyProjectTOML
    participant Dependency

    Poetry->>PyProjectTOML: Get build_system
    PyProjectTOML-->>Poetry: Return build system config
    loop For each requirement
        Poetry->>Dependency: create_from_pep_508(requirement)
        alt PEP 508 parsing successful
            Dependency-->>Poetry: Return Dependency instance
        else PEP 508 parsing failed
            Note over Poetry: Try as file/directory path
            alt Is file
                Poetry->>Poetry: Create FileDependency
            else Is directory
                Poetry->>Poetry: Create DirectoryDependency
            end
        end
    end
Loading

Class diagram showing Poetry class modifications

classDiagram
    class Poetry {
        -_build_system_dependencies: list[Dependency]
        +pyproject: PyProjectTOML
        +package: ProjectPackage
        +local_config: dict[str, Any]
        +build_system_dependencies: list[Dependency]
        +get_project_config(config: str, default: Any): Any
    }

    class Dependency {
        +create_from_pep_508(requirement: str): Dependency
    }

    class FileDependency {
        +name: str
        +path: Path
    }

    class DirectoryDependency {
        +name: str
        +path: Path
    }

    Poetry --> "*" Dependency : has
    FileDependency --|> Dependency : extends
    DirectoryDependency --|> Dependency : extends

    note for Poetry "New property build_system_dependencies
parses requirements into Dependency objects"
Loading

File-Level Changes

Change Details Files
Expose build-system dependencies as Dependency instances
  • Added a new property build_system_dependencies to the Poetry class that returns a list of Dependency objects representing the build-system dependencies.
  • Added tests to verify the functionality of the new property, including cases with various dependency types (PEP 508 strings, directory dependencies, and file dependencies).
src/poetry/core/poetry.py
tests/test_factory.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.
  • 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

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 @abn - I've reviewed your changes - here's some feedback:

Overall Comments:

  • The test appears to have issues: there's a typo in the parameter name 'requries' and the test implementation doesn't match the parametrized cases - it only tests 'sample_project' while declaring two different test scenarios.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟡 Testing: 3 issues found
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

src/poetry/core/poetry.py Show resolved Hide resolved
tests/test_factory.py Outdated Show resolved Hide resolved
tests/test_factory.py Outdated Show resolved Hide resolved
tests/test_factory.py Outdated Show resolved Hide resolved
Copy link
Member

@finswimmer finswimmer left a comment

Choose a reason for hiding this comment

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

Just a small thing.

src/poetry/core/poetry.py Outdated Show resolved Hide resolved
@abn abn force-pushed the build-system-requires branch from 7bd850e to 13ad55a Compare January 17, 2025 12:15
@abn
Copy link
Member Author

abn commented Jan 17, 2025

@sourcery-ai review

@abn abn requested a review from finswimmer January 17, 2025 12:17
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 @abn - I've reviewed your changes - here's some feedback:

Overall Comments:

  • There appears to be a bug in the logging - the 'Skipping build system dependency' debug message is logged when a dependency is successfully added, which is incorrect. The log message should either be moved to the else branch when skipping, or the message should be changed to indicate successful addition.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟡 Testing: 1 issue found
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

src/poetry/core/poetry.py Show resolved Hide resolved
tests/test_factory.py Show resolved Hide resolved
@abn abn force-pushed the build-system-requires branch from 13ad55a to f0c2db9 Compare January 17, 2025 12:20
@abn abn enabled auto-merge (rebase) January 17, 2025 12:23
@abn abn merged commit 528e796 into python-poetry:main Jan 17, 2025
18 checks passed
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.

3 participants