docs/fix: clarify shortcut key must be lowercase a–z or digit 0–9#487
Open
ttw225 wants to merge 2 commits intotmbo:masterfrom
Open
docs/fix: clarify shortcut key must be lowercase a–z or digit 0–9#487ttw225 wants to merge 2 commits intotmbo:masterfrom
ttw225 wants to merge 2 commits intotmbo:masterfrom
Conversation
clarify shortcut_key allows only a-z and 0-9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Questionary is an awesome work!!
I've been using it comfortably alongside Commitizen and followed the same patterns when building CLI flows.
What is the problem that this PR addresses?
One small pain point is the shortcut key story: when
use_shortcutsis on (e.g.select,rawselect), choices can take a dictkey(orChoice(..., shortcut_key=...)), but the docs and the thrown error didn’t spell out the real rule clearly.The allowed set is already defined in code as
InquirerControl.SHORTCUT_KEYS—only single digits 0–9 and single lowercase letters a–z. The previous error text said shortcuts “should be single characters or numbers,” which is easy to read as “any single character,” so users can hit a confusingValueError(e.g. using an uppercase letter) without knowing why....
How did you solve it?
Choice’sshortcut_keyparameter, and theshortcut_keyproperty so they state explicitly that values must be a single lowercase letter (a–z) or digit (0–9), matchingSHORTCUT_KEYS._assign_shortcut_keys()with a clear message and fixed the missing space between"Invalid shortcut '…'"and"for choice …"....
Example (invalid key — uppercase
X):Resulting error text:
Original error text:
Checklist