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

Silently allow --no-update for backward compatibility #10164

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

Conversation

leonardgerardatomicmachinescom
Copy link

@leonardgerardatomicmachinescom leonardgerardatomicmachinescom commented Feb 10, 2025

The error The option "--no-update" does not exist is not necessary since no update is anyway the default. Erroring does not help. Contrarily, it prevents scripts or automated uses to work with both v1 and v2.

(I work in a place with shared build scripts, but users control which version of poetry they use, so when one installs poetry v2, it fails with the --no-update flag error).

Pull Request Check List

Resolves: #issue-number-here

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

Summary by Sourcery

Tests:

  • Add tests to verify the behavior of the --no-update flag and its incompatibility with the --regenerate flag.

Copy link

sourcery-ai bot commented Feb 10, 2025

Reviewer's Guide by Sourcery

This pull request introduces support for the '--no-update' flag to allow backward compatibility by silently allowing its usage. The changes ensure that when '--no-update' is provided with the lock command, the locked packages are not updated, and proper error handling has been added when both '--no-update' and '--regenerate' are used simultaneously. Test cases have been updated to verify the new behavior.

Updated class diagram for LockCommand in LockCommand handling

classDiagram
    class LockCommand {
      +List options
      +handle() int
    }
    %% New option added for backward compatibility
    class LockCommandOptions {
      +"--no-update": boolean
      +"--regenerate": boolean
    }
    LockCommand --> LockCommandOptions : uses
    note for LockCommand "The '--no-update' option is added for backward compatibility. In handle(), if both '--no-update' and '--regenerate' are present, an error is displayed and returns 1."
Loading

File-Level Changes

Change Details Files
Update test cases to validate the --no-update functionality.
  • Parametrized the test for lock command to run with both '--no-update' true and false.
  • Modified the test to conditionally execute the '--no-update' flag depending on the provided parameter.
  • Added a new test to verify that using '--no-update' together with '--regenerate' returns an error.
tests/console/commands/test_lock.py
Implement the '--no-update' option and enforce mutual exclusivity with '--regenerate'.
  • Introduced the '--no-update' option in the lock command options list.
  • Added logic in the handle method to check if both '--no-update' and '--regenerate' are set, output an error message and return an error code.
  • Updated the lock command execution to respect the '--no-update' flag by controlling the update behavior during the locking process.
src/poetry/console/commands/lock.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. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the 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 exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

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

Overall Comments:

  • Consider using pytest.mark.parametrize to avoid repeating the same assertion logic in test_no_update_and_regenerate_at_the_same_time.
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.

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