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

mark dry run in Poetry output #9973

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

piotr-kubiak
Copy link

@piotr-kubiak piotr-kubiak commented Jan 6, 2025

Pull Request Check List

A proposed fix for #9972.

  • Added tests for changed code.

Summary by Sourcery

Tests:

  • Add tests to verify the output of the commands.

Copy link

sourcery-ai bot commented Jan 6, 2025

Reviewer's Guide by Sourcery

This pull request marks dry runs in Poetry output, addressing issue #9972. It modifies several test files to assert the presence of "Running in DRY RUN mode" in the output when the --dry-run flag is used. It also modifies the version, publish, update, install, and remove commands to print "Running in DRY RUN mode" to the console when the --dry-run flag is used.

Sequence diagram for dry run mode output in Poetry commands

sequenceDiagram
    actor User
    participant CLI
    participant Command
    participant IO

    User->>CLI: Execute command with --dry-run
    CLI->>Command: handle()
    alt dry-run option enabled
        Command->>IO: write_line('Running in DRY RUN mode')
    end
    Command->>IO: write regular command output
    IO-->>User: Display output
Loading

Class diagram showing modified Poetry commands

classDiagram
    class IO {
        +write_line(text: str)
    }

    class Command {
        +handle(): int
        +option(name: str): Any
        #_io: IO
    }

    class VersionCommand {
        +handle(): int
    }

    class Publisher {
        +publish()
        #_io: IO
    }

    class Installer {
        +run(): int
        +is_dry_run(): bool
        #_io: IO
    }

    Command <|-- VersionCommand
    Command --> IO
    Publisher --> IO
    Installer --> IO

    note for Command "Modified to show dry-run mode"
    note for Publisher "Added dry-run output"
    note for Installer "Added dry-run output"
Loading

File-Level Changes

Change Details Files
Added assertions to test the output of dry run commands.
  • Added assertions to check for the presence of "Running in DRY RUN mode" in the output when the --dry-run flag is used.
  • Modified existing assertions to account for the new output string.
  • Removed unnecessary assertions that are no longer relevant.
tests/console/commands/test_publish.py
tests/console/commands/test_version.py
tests/console/commands/test_install.py
tests/console/commands/test_update.py
tests/console/commands/self/test_remove_plugins.py
Modified commands to print "Running in DRY RUN mode" when the --dry-run flag is used.
  • Added a conditional statement to print "Running in DRY RUN mode" to the console when the --dry-run flag is used.
  • Refactored existing code to accommodate the new output string.
src/poetry/console/commands/version.py
src/poetry/publishing/publisher.py
src/poetry/installation/installer.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 @piotr-kubiak - 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.

@Secrus Secrus requested a review from a team January 7, 2025 09:44
@abn
Copy link
Member

abn commented Jan 7, 2025

If I recall correctly, the output is intentionally similar. I don't think there is a need for this change. Happy to hear from others before deciding.

If we do proceed, I do think the message will have to change.

@piotr-kubiak
Copy link
Author

@abn Sorry to hear that. I explained my rationale for this change in the original issue #9972.

@radoering
Copy link
Member

I do not have a strong opinion. I see benefits on both sides.

@Secrus
Copy link
Member

Secrus commented Jan 8, 2025

I don't mind adding some markers about the simulation mode, but I agree the message should be different.

@piotr-kubiak piotr-kubiak marked this pull request as draft January 8, 2025 15:01
@piotr-kubiak
Copy link
Author

I am more than happy to change the message, but not sure what it should be.
Here are some examples in other tools:

$ rsync --dry-run -av foo/ bar/
sending incremental file list
./

sent 95 bytes  received 19 bytes  228.00 bytes/sec
total size is 0  speedup is 0.00 (DRY RUN)

$ pip install --dry-run six
Collecting six
  Using cached six-1.17.0-py2.py3-none-any.whl.metadata (1.7 kB)
Using cached six-1.17.0-py2.py3-none-any.whl (11 kB)
Would install six-1.17.0

$ git clean -fd --dry-run
Would remove bar/
Would remove foo/

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.

4 participants