poetry icon indicating copy to clipboard operation
poetry copied to clipboard

Silently allow --no-update for backward compatibility

Open leonardgerardatomicmachinescom opened this issue 10 months ago • 4 comments

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

  • [X] Added tests for changed code.
  • [X] 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.

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."

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

  • 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 Feb 10 '25 05:02 sourcery-ai[bot]

Not sure if this still makes sense after such a long time and so few complaints (resp. so few "thumbs up" on this PR). I think we should have printed a deprecation warning instead of just removing it in the first place but now it is probably just fine to leave it alone?

radoering avatar Sep 13 '25 07:09 radoering

Consequence for us is that we stuck to poetry v1 and will probably move to some other toolchain rather than upgrade to v2.

Note that some other cli breakage led to the full decision, a major one being v2 poetry -C <dir> not behaving like all other linux tools (does not change the CWD).

Consequence for us is that we stuck to poetry v1 and will probably move to some other toolchain rather than upgrade to v2.

Does that mean that this PR would still help you if included in the next minor release or that it does not matter to you? In case, you are still interested in getting this merged, would it be fine for you if we print a deprecation warning if --no-update is used?

a major one being v2 poetry -C <dir> not behaving like all other linux tools (does not change the CWD).

I think that one was fixed in #9831 with Poetry 2.0.0.

radoering avatar Sep 13 '25 07:09 radoering