poetry icon indicating copy to clipboard operation
poetry copied to clipboard

feat(source/show): notify when PyPI is implicit

Open abn opened this issue 11 months ago • 1 comments

Add a notice when all sources are listed and PyPI is implicitly enabled.

Summary by Sourcery

Add a notification to inform users when PyPI is implicitly enabled as a primary source and update tests to verify this behavior.

New Features:

  • Add a notification feature to inform users when PyPI is implicitly enabled as a primary source.

Tests:

  • Introduce a test to verify the notification for implicit PyPI when no sources are configured.

abn avatar Jan 07 '25 00:01 abn

Reviewer's Guide by Sourcery

This pull request introduces a notification feature to inform users when PyPI is implicitly enabled as a primary source in the 'source show' command. It adds a new method to handle this notification and updates the command logic to trigger it appropriately. Additionally, a test case is added to ensure the notification works as expected.

Sequence diagram for source show command with implicit PyPI notification

sequenceDiagram
    actor User
    participant CLI as Poetry CLI
    participant ShowCmd as SourceShowCommand
    participant Pool as Poetry Pool

    User->>CLI: poetry source show
    CLI->>ShowCmd: handle()
    ShowCmd->>ShowCmd: get_sources()
    alt no sources configured
        ShowCmd->>ShowCmd: notify_implicit_pypi()
        ShowCmd->>Pool: has_repository('pypi')
        Pool-->>ShowCmd: true/false
        ShowCmd-->>User: Display implicit PyPI notice
    else sources exist
        loop for each source
            ShowCmd->>ShowCmd: Display source info
        end
        alt PyPI not explicitly configured
            ShowCmd->>ShowCmd: notify_implicit_pypi()
            ShowCmd->>Pool: has_repository('pypi')
            Pool-->>ShowCmd: true/false
            ShowCmd-->>User: Display implicit PyPI notice
        end
    end

Class diagram for updated SourceShowCommand

classDiagram
    class SourceShowCommand {
        +handle(): int
        +notify_implicit_pypi(): None
    }
    note for SourceShowCommand "Added notify_implicit_pypi() method
to handle PyPI implicit source notification"

File-Level Changes

Change Details Files
Added notification for implicit PyPI source.
  • Introduced a new method notify_implicit_pypi to handle the notification.
  • Called notify_implicit_pypi in handle method when no sources are configured.
  • Checked if PyPI is implicitly enabled and called notify_implicit_pypi accordingly.
src/poetry/console/commands/source/show.py
Added test for implicit PyPI notification.
  • Imported PyPiRepository for testing purposes.
  • Added test case test_source_show_no_sources_implicit_pypi to verify the notification when PyPI is implicit.
tests/console/commands/source/test_show.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

  • Contact our support team for questions or feedback.
  • Visit our documentation for detailed guides and information.
  • Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.

sourcery-ai[bot] avatar Jan 07 '25 00:01 sourcery-ai[bot]

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Feb 10 '25 00:02 github-actions[bot]