-
Notifications
You must be signed in to change notification settings - Fork 307
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 --non-interactive flag #489
Conversation
When set, abort instead of interactively prompting for username/password when the required environment variables are missing.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Generate the appropriate behavior (prompt vs. raise exception) in get_username and get_password via a helper method rather than passing the non-interactive flag down through all the helper functions. This allows the later helper functions to be reverted back to their original, simpler forms.
A few questions on the testing: Going through the existing tests, I believe there only needs to be tests added to
Am I missing anything that should be covered? Also, as a result of the changes to the signature of |
Add default value to non_interactive input to get_username and get_password to preserve the behavior of existing tests
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.
The logic and CLI looks good to me, though of course the maintainers will need to review.
Thanks for jumping on this, @sco1!
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.
Thank you for working on this issue. It seems to be quite important.
A few concerns:
- The implementation as proposed weaves a boolean variable through several function calls. I'll want to first identify a refactoring that limits the number of code blocks that this one option touches.
- I'd prefer instead of a boolean option to provide more descriptive options like "prompt: disable" or "secrets-from: env,keyring,pypirc,prompt" (a broader technique that lets the caller define or exclude the techniques attempted; there's already an option to bypass keyring).
- Does the implementation support TWINE_NON_INTERACTIVE environment variable in addition to the command line option? I think it should.
- (more of a comment than an action) I don't think this implementation prevents keyring from raising an interactive prompt. I think that's reasonable, given that the user could avoid keyring implementations that might be interactive or disable keyring entirely if appropriate. Unless keyring provided a similar non-interactive awareness, there's not much twine could do to relay that information.
Oh that's a good point. Perhaps, since you're here, we could just decide to support
The downside of the We have a long enough history of simple do-not-prompt options that I think it's fine to keep it simple. (The "bypass" keyring option is specifically to bypass the |
@jaraco looks like there are some follow-up questions to your suggestion. Can you offer feedback? Also, I second this suggestion:
|
I agree with Zooba. Simple is better. Let's just see if we can get the code to be less intrusive and iterate from there... or maybe accept the change and defer refactoring for another day.
I was actually traveling and just eeked out my suggestions between flights. I'm not sure a |
I should have asked this a while ago, but just to make sure I haven't assumed incorrectly:
Am I correct in assuming this is intended as a PyPA task? With the help of the review comments I've tried to make the value as least touchy as possible but I'm not sure how much further I know how to take it without refactoring the configuration system itself, which I'm not familiar enough with Twine to feel comfortable undertaking. I believe adding the env var support is a one-liner (+tests), but wanted to make sure the config system wasn't being refactored before pushing. |
Today, I took a look at implementing the refactoring, and I wasn't happy with anything that I could come up with on short notice, but I have some more ideas I'll explore later. And so no, I don't want to block this effort any more. I'll accept the change as proposed, and you can add support for the environment variable in a separate PR. |
Will take a look at the env var this week, thanks for all the help & feedback! |
Per #334, this adds a
--non-interactive
flag that aborts (via a newNonInteractive
exception) instead of interactively prompting for username and/or password if the required credentials are missing.Fixes #334.