How to use the cfgv.validate function in cfgv

To help you get started, we’ve selected a few cfgv examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pre-commit / pre-commit / testing / fixtures.py View on Github external
def make_config_from_repo(repo_path, rev=None, hooks=None, check=True):
    manifest = load_manifest(os.path.join(repo_path, C.MANIFEST_FILE))
    config = {
        'repo': 'file://{}'.format(repo_path),
        'rev': rev or git.head_rev(repo_path),
        'hooks': hooks or [{'id': hook['id']} for hook in manifest],
    }

    if check:
        wrapped = validate({'repos': [config]}, CONFIG_SCHEMA)
        wrapped = apply_defaults(wrapped, CONFIG_SCHEMA)
        config, = wrapped['repos']
        return config
    else:
        return config
github asottile / git-code-debt / git_code_debt / generate_config.py View on Github external
def from_yaml(cls, dct):
        dct = cfgv.apply_defaults(cfgv.validate(dct, SCHEMA), SCHEMA)
        return cls(
            skip_default_metrics=dct['skip_default_metrics'],
            metric_package_names=dct['metric_package_names'],
            repo=dct['repo'],
            database=dct['database'],
            exclude=re.compile(dct['exclude'].encode()),
        )