How to use the pydocstyle.config function in pydocstyle

To help you get started, we’ve selected a few pydocstyle 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 henry0312 / pytest-docstyle / src / pytest_pydocstyle.py View on Github external
def pytest_collect_file(parent, path):
    config = parent.config
    if config.getoption('pydocstyle') and path.ext == '.py':
        parser = pydocstyle.config.ConfigurationParser()
        args = [str(path.basename)]
        with _patch_sys_argv(args):
            parser.parse()
        for filename, _, _ in parser.get_files_to_check():
            # https://github.com/pytest-dev/pytest/blob/ee1950af7793624793ee297e5f48b49c8bdf2065/src/_pytest/nodes.py#L477
            return File.from_parent(parent=parent, fspath=path, config_parser=parser)
github palantir / python-language-server / pyls / plugins / pydocstyle_lint.py View on Github external
if settings.get('convention'):
        args.append('--convention=' + settings['convention'])

        if settings.get('addSelect'):
            args.append('--add-select=' + ','.join(settings['addSelect']))
        if settings.get('addIgnore'):
            args.append('--add-ignore=' + ','.join(settings['addIgnore']))

    elif settings.get('select'):
        args.append('--select=' + ','.join(settings['select']))
    elif settings.get('ignore'):
        args.append('--ignore=' + ','.join(settings['ignore']))

    log.info("Using pydocstyle args: %s", args)

    conf = pydocstyle.config.ConfigurationParser()
    with _patch_sys_argv(args):
        # TODO(gatesn): We can add more pydocstyle args here from our pyls config
        conf.parse()

    # Will only yield a single filename, the document path
    diags = []
    for filename, checked_codes, ignore_decorators in conf.get_files_to_check():
        errors = pydocstyle.checker.ConventionChecker().check_source(
            document.source, filename, ignore_decorators=ignore_decorators
        )

        try:
            for error in errors:
                if error.code not in checked_codes:
                    continue
                diags.append(_parse_diagnostic(document, error))