loganasherjones / yapconf

Yet Another Python Configuration
http://yapconf.readthedocs.io/en/stable/
MIT License
18 stars 4 forks source link

Boolean items fallback #85

Closed hazmat345 closed 6 years ago

hazmat345 commented 6 years ago

I'm seeing some weirdness when trying to use fallbacks for boolean items. Is there any reason you can think of why they would behave differently?

SPEC_DEF = {
    'ssl': {
        'type': 'dict',
        'items': {
            'enabled': 
                'type': 'bool',
                'default': False,
            },
        }
    },
    'web':
        'type': 'dict',
        'items': {
            "ssl_enabled": {
                "type": "bool",
                "default": False,
                "description": "Is the API server using SSL",
                "previous_names": ["ssl_enabled"],
                "alt_env_names": ["SSL_ENABLED"],
                "cli_separator": "_",
                "fallback": "ssl.enabled",
            },
        },
    },
}

Setting ssl.enabled to True doesn't result in web.ssl_enabled being True as well.

Now that I'm looking more, maybe it's applying the default before checking for a fallback? Does it not make sense to have default and fallback specified on the same item?

hazmat345 commented 6 years ago

...and ignore me. This was definitely an issue of a fallback combined with a default. I can add something to the docs to make it clear that this is a bad idea.