Skip to content
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

Added customization to the illegal_choice_message. #3247

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

SamuelMorrisProjects
Copy link

Type of changes

  • Bug fix
  • [ x] New feature
  • [ x] Documentation / docstrings
  • Tests
  • Other

Checklist

  • I've run the latest black with default args on new code.
  • [ x] I've updated CHANGELOG.md and CONTRIBUTORS.md where appropriate.
  • I've added tests for new code.
  • [ x] I accept that @willmcgugan may be pedantic in the code review.

Description

I made the illegal_choice_message an optional parameter of the both the class prompt and the method ask in prompt.py. The illegal choice parameter automatically defaults to the original Text Type("[prompt.invalid.choice]Please select one of the available options."). This will allow those using the library to customize the message that is outputted to the user. I also updated the documentation to reflect this change.

Why

I added this feature because to my knowledge—please correct me if I am wrong in this assumption—there is no way to change the error message outputted when a user does not pick one of the choices. I am somewhat new to programming so I could have missed something. I also feel this change will produce overall more robust code.

Examples

Code:
image
Output:
image

Made the illegal choice message an optional parameter that defaults to [prompt.invalid.choice]Please select one of the available options.
Cleaned up some unneeded changes.
Removed unnecessary () and changed Float Prompt back to its original state.
Updated prompt documentation to explain the parameter, illegal choice message.
Changed the docstrings for the parameter illegal choice message.
Fixed minor formatting issues in the documentation
Added a description of my change to the change log.
Added my name to the CONTRIBUTORS.md :)
@SamuelMorrisProjects SamuelMorrisProjects changed the title Added increased Functionality to Prompt.py Added user customization to the illegal_choice_message. Jan 5, 2024
@SamuelMorrisProjects SamuelMorrisProjects changed the title Added user customization to the illegal_choice_message. Added customization to the illegal_choice_message. Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant