-
-
Notifications
You must be signed in to change notification settings - Fork 611
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
Add --ask option to pip-sync #913
Conversation
@atugushev Please could you review? |
181baea
to
90b8a3b
Compare
Codecov Report
@@ Coverage Diff @@
## master #913 +/- ##
=========================================
+ Coverage 98.58% 98.6% +0.02%
=========================================
Files 35 35
Lines 2264 2300 +36
Branches 290 298 +8
=========================================
+ Hits 2232 2268 +36
Misses 21 21
Partials 11 11
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @georgek! I like the way you've refactored sync
. A few comments. I think we shouldn't change dry_run
value during runtime, but check ask
explicitly instead. Here are the changes I propose:
tests/test_sync.py
Outdated
@@ -437,6 +437,64 @@ def test_sync_dry_run_would_uninstall(echo, from_line): | |||
echo.assert_has_calls(expected_calls, any_order=True) | |||
|
|||
|
|||
@mock.patch("piptools.sync.click.confirm") | |||
@mock.patch("piptools.sync.click.echo") | |||
def test_sync_ask_declined_would_install(echo, confirm, from_line): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests test_sync_ask_declined_would_install
and test_sync_ask_declined_would_uninstall
looks almost the same. Could we use parametrization instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be done but it's a bit awkward. Since I tried to mirror the tests test_sync_dry_run_would_uninstall
and test_sync_dry_run_would_install
I have also parameterised these as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost done! Great work 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Thanks @atugushev! Please let me know when I should squash/rebase etc. |
Yes, please, squash and rebase it. |
004333f
to
1269d78
Compare
Thanks, @georgek! Awesome work! 👍 |
This adds an
--ask
option to pip-sync which will first show the user what would change, like--dry-run
, and then ask to confirm before continuing with the changes. This is supposed to address issue #671 without breaking existing workflows (in particular CI pipelines) and in a way that is well-established by existing tools like nmcli (network manager) and portage (Gentoo package manager).This change requires a minor version bump.
Changelog-friendly one-liner: Add
--ask
option topip-sync
.Contributor checklist