Fix config file type coercion (Issue 311)#450
Open
rannoww wants to merge 1 commit intotrailofbits:masterfrom
Open
Fix config file type coercion (Issue 311)#450rannoww wants to merge 1 commit intotrailofbits:masterfrom
rannoww wants to merge 1 commit intotrailofbits:masterfrom
Conversation
configparser returns all values as strings regardless of intended type. We built a type map from argparse's registered actions and use it in build_from_config() to force values to the correct types before they merge into pared args. FIxes#311
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.
Fixes #311
configparserreturns all values as strings, so arguments liketimeoutandmem_limitloaded from a config file were stored as"36000"instead of36000, causing aTypeErrorat runtime whenarithmetic was performed on them.
Changes
type_mapparameter tobuild_from_config()thatmaps argument names to their expected types
parse_args(), build that type map from argparse's registeredactions and pass it into
build_from_config()store_true/store_falseboolean actions as a special case##Notes
-Done for class CS386 group members Tate Rannow and Zain Elsafty. I am submitting the PR for the both of us.