(options: 'KeyedOptionDictType', opt: OptionKey, fallback: '_T')
return v
Get the value of an option, or the fallback value.
Get the value of an option, or the fallback value.
Get the value of an option or the fallback value .
def get_option_value(options: 'KeyedOptionDictType', opt: OptionKey, fallback: '_T') -> '_T':
    """Get the value of an option, or the fallback value."""
    try:
        v: '_T' = options[opt].value
    except KeyError:
        return fallback

    assert isinstance(v, type(fallback)), f'Should have {type(fallback)!r} but was {type(v)!r}'
    # Mypy doesn't understand that the above assert ensures that v is type _T
    return v
def get_option_value ( options : 'KeyedOptionDictType' , opt : OptionKey , fallback : '_T' ) -> '_T' : try : v : '_T' = options [ opt ] . value except KeyError : return fallback assert isinstance ( v , type ( fallback ) ) , f'Should have {type(fallback)!r} but was {type(v)!r}' # Mypy doesn't understand that the above assert ensures that v is type _T return v