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

PEP 753 #807

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

PEP 753 #807

wants to merge 1 commit into from

Conversation

dimbleby
Copy link
Contributor

@dimbleby dimbleby commented Jan 6, 2025

Also fixes python-poetry/poetry#9957

PEP 753 says

When generating metadata 1.2 or later, producers SHOULD emit only Project-URL, and SHOULD NOT emit Home-page or Download-URL fields.

since this is all kinda broken at the moment anyway - #803 etc - it is a good opportunity to fix that

Breaks a couple of downstream tests that expect "Home-page" and do not expect the "Project-URL: Homepage". I suppose we could do that horrid dance where poetry tests briefly tolerate both. But anticipating that there will surely be new releases fairly promptly of both projects - for various bits of 2.0 fallout - perhaps we can skip that unpleasantness and tolerate the downstream tests being broken for a small window...

Summary by Sourcery

Update metadata generation to follow PEP 753. Emit "Project-URL" instead of "Home-page" or "Download-URL".

Enhancements:

  • Standardize URL handling in metadata generation.

Tests:

  • Update tests to reflect the changes in URL presentation in metadata.

Copy link

sourcery-ai bot commented Jan 6, 2025

Reviewer's Guide by Sourcery

This PR implements PEP 753 by migrating from the use of Home-page and Download-URL fields to the sole use of Project-URL fields for package metadata. It also fixes inconsistencies in handling URLs and cleans up URL-related code.

Sequence diagram for updated URL metadata handling

sequenceDiagram
    participant Package
    participant Factory
    participant Metadata

    Factory->>Package: Configure package metadata
    Note over Factory: Process URLs from project config
    Factory->>Package: Set homepage
    Factory->>Package: Set repository_url
    Factory->>Package: Set documentation_url
    Factory->>Package: Set custom_urls

    Package->>Metadata: Convert to metadata
    Note over Metadata: Generate project_urls
    Note over Metadata: No longer includes Home-page field
Loading

Class diagram for metadata handling changes

classDiagram
    class Package {
        +homepage: str
        +repository_url: str
        +documentation_url: str
        +custom_urls: dict
        +urls: dict
    }

    class Metadata {
        +project_urls: tuple
        +home_page: str
        -from_package(package: Package)
        +get_metadata_content()
    }

    class Factory {
        -_configure_package_metadata()
    }

    Factory ..> Package: configures
    Package ..> Metadata: converts to
    note for Metadata "Removed Home-page field
Only uses Project-URL"
Loading

File-Level Changes

Change Details Files
Migrated to using Project-URL for homepage and other URLs, removing Home-page field
  • Updated _configure_package_metadata to populate package.homepage from the urls dictionary and store other URLs in package.custom_urls.
  • Modified Metadata.from_package to generate Project-URL entries from the package.urls dictionary.
  • Removed the Home-page field generation from get_metadata_content.
  • Updated tests to reflect the change from Home-page to Project-URL for homepage.
  • Adjusted tests to expect Project-URL: Homepage instead of Home-page.
  • Modified tests to check for the absence of Home-page and the presence of Project-URL: Homepage.
  • Updated tests to reflect the changes in URL handling and the removal of the Home-page field from metadata.
src/poetry/core/factory.py
src/poetry/core/masonry/metadata.py
src/poetry/core/masonry/builders/builder.py
tests/masonry/builders/test_builder.py
tests/masonry/builders/test_complete.py
tests/masonry/test_api.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 @dimbleby - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 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.

@dimbleby dimbleby changed the title PEP 753, also fixes https://github.com/python-poetry/poetry/issues/9957 PEP 753 Jan 6, 2025
dimbleby added a commit to dimbleby/poetry that referenced this pull request Jan 6, 2025
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.

Can not install package in CI
1 participant