SkygearIO / py-skygear

Skygear Cloud Code Python SDK
https://skygear.io
Other
8 stars 20 forks source link

SettingsParser default value should not pass to atype function #187

Closed rickmak closed 6 years ago

rickmak commented 6 years ago

The atype function should only run if the value is provided by the duser

Expected Results

The atype function should not accept the default value, and it should safely assume the pass in value is a string from envvar or command line.

Actual Results

The atype function will accept the default value, making the developer need to handle type and return. resulting following code:

def get_provider_enabled(enabled):
    if isinstance(enabled, bool):
        return enabled

    try:
        return strtobool(enabled)
    except ValueError:
        return False

The isinstance check should not be required.