Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
Crissal1995 wants to merge9 commits intoprompt-toolkit:main
base:main
Choose a base branch
Loading
fromCrissal1995:master

Conversation

@Crissal1995
Copy link

This PRresolves#1783.
ThePasswordProcessor by 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. likegetpass does.
Two tests were added, and the example was also modified and tested locally to make sure that the change works as intended.

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.

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.

Copy link
Author

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?

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.

Copy link
Author

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.

@Crissal1995
Copy link
Author

Crissal1995 commentedJan 20, 2025
edited
Loading

Apparently running the tests withpytest leads to a different result (green testsuite) than the one obtained by the command used by the CI pipeline,coverage run -m pytest (red testsuite); I am not sure why this is the case.

EDIT: Found an unrelated bug related to thePrompt - or thePlainTextOutput? - where the output is duplicated when it should not be.
The test is now handling this bad-weather case scenario.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@jonathanslendersjonathanslendersAwaiting requested review from jonathanslenders

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Hide password instead of replacing it with a character

2 participants

@Crissal1995@jonathanslenders

[8]ページ先頭

©2009-2025 Movatter.jp