Repository navigation
Conversation
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.
PR Description
This PR adds a new module (KLQueries) for easily prompting and validating keyboard input from users. This was previously technically possible with horrendous abuse of the
queryfunction in KLCommunications (or adding custom 'experimental' queries to theuser_queries.jsonfile), but this module provides the same functionality (and more) with a much cleaner and simpler API.Currently, the KLQueries module provides 3 Query classes: NumberQuery, ChoiceQuery, and TextQuery, each for different types of responses. NumberQueries ensure that the user's response is numeric and enforces upper and lower bounds on the response. ChoiceQueries are for multiple-choice queries and ensure the response is one of a set of possible options, and TextQueries are for free-form text responses (with optional limits on the minimum/maximum number of characters). The module also provides the QueryStyle class for customizing the location and appearance of queries.
A FormatQuery class that requires responses follow a regex-style format (e.g. "P###") is planned for the future.
In addition to the new module itself, the
blitfunction has also been fully re-documented with a proper explanation of thelocationandregistrationparameter, which was necessary in order to reference the explanation in the documentation for QueryStyle.This PR is intended to completely remove the need for
KLCommunication.queryfrom the public API (currently only used in BaseballTOJ and TraceLab) and lay the groundwork for replacinguser_queries.jsonitself with a more flexible and more readable pure-Python equivalent.Merge Checklist
closes #<issue-number>to automatically close an issue