- Notifications
You must be signed in to change notification settings - Fork759
Hide password during typing with a new prompt input#1962
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
New input added to the prompt(): hide_passwordFalse by default, if True, the characters won't be echoed back (as *) in the output
| When True (the default), automatically wrap long lines instead of | ||
| scrolling horizontally. | ||
| :param is_password: Show asterisks instead of the actual typed characters. | ||
| :param hide_password: Hide the password, rather than showing asterisks. |
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.
Would it make sense to acceptpassword_character here instead ofhide_password? It will be more flexible.
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.
Undoubtedly, but from an user perspectivehide_password is more clear.
Besides, is there any valuable use-case where the password is displayed as something else, e.g.xxxxx or11111?
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.
I can imagine that some might want to render it as Unicode bullets, because that's more beautiful.
Likepassword_character="•"
I mainly want to avoid having too many redundant arguments here. We have to repeat them in multiple places and the signature gets pretty long. If at some point, some users want to configure this, we'll have bothhide_password andpassword_character.
Honestly, I'm not sure myself. If there was some prior art in other libraries, that could convince me to go one way or another.
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.
An alternative would be to use both flags, forcingpassword_character to be an empty string ifhide_password isTrue.
In this way users could either use the flaghide_password if they don't care about how the password is displayed on screen, or the flagpassword_character if they want to customize the appearance, as youy suggested.
Uh oh!
There was an error while loading.Please reload this page.
Crissal1995 commentedJan 20, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Apparently running the tests with EDIT: Found an unrelated bug related to the |
This PRresolves#1783.
The
PasswordProcessorby default (current implementation, no argument given) outputs a*for each letter typed by the user in the prompt.However, the desired behavior would be to make the typed password invisible, e.g. like
getpassdoes.Two tests were added, and the example was also modified and tested locally to make sure that the change works as intended.