def _generate_help_dicts(config_cls, _prefix=None):
    """
    Generate dictionaries for use in building help strings.

    Every dictionary includes the keys...

    var_name: The env var that should be set to populate the value.
    required: A bool, True if the var is required, False if it's optional.

    Conditionally, the following are included...

    default: Included if an optional variable has a default set
    help_str: Included if the var uses the help kwarg to provide additional
        context for the value.

    Conditional key inclusion is meant to differentiate between exclusion
    vs explicitly setting a value to None.
    """
    help_dicts = []
    if _prefix is None:
        _prefix = config_cls._prefix
    for a in attr.fields(config_cls):
        try:
            ce = a.metadata[CNF_KEY]
        except KeyError:
            continue
        if ce.sub_cls is None:  # Base case for "leaves".
            if ce.name is None:
                var_name = "_".join((_prefix, a.name)).upper()
            else:
                var_name = ce.name
            req = ce.default == RAISE
            help_dict = {"var_name": var_name, "required": req}
            if not req:
                help_dict["default"] = ce.default
            if ce.help is not None:
                help_dict["help_str"] = ce.help
            help_dicts.append(help_dict)
        else:  # Construct the new prefix and recurse.
            help_dicts += _generate_help_dicts(
                ce.sub_cls, _prefix="_".join((_prefix, a.name)).upper()
            )
    return help_dicts
def _generate_help_dicts ( config_cls , _prefix = None ) : help_dicts = [ ] if _prefix is None : _prefix = config_cls . _prefix for a in attr . fields ( config_cls ) : try : ce = a . metadata [ CNF_KEY ] except KeyError : continue if ce . sub_cls is None : if ce . name is None : var_name = "_" . join ( ( _prefix , a . name ) ) . upper ( ) else : var_name = ce . name req = ce . default == RAISE help_dict = { "var_name" : var_name , "required" : req } if not req : help_dict [ "default" ] = ce . default if ce . help is not None : help_dict [ "help_str" ] = ce . help help_dicts . append ( help_dict ) else : help_dicts += _generate_help_dicts ( ce . sub_cls , _prefix = "_" . join ( ( _prefix , a . name ) ) . upper ( ) ) return help_dicts
Generate dictionaries for use in building help strings.

    Every dictionary includes the keys...

    var_name: The env var that should be set to populate the value.
    required: A bool, True if the var is required, False if it's optional.

    Conditionally, the following are included...

    default: Included if an optional variable has a default set
    help_str: Included if the var uses the help kwarg to provide additional
        context for the value.

    Conditional key inclusion is meant to differentiate between exclusion
    vs explicitly setting a value to None.