How to use the pydocstyle.config.ConfigurationParser 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 dickreuter / neuron_poker / tests / test_pylint.py View on Github external
def run_pydocstyle():
    """Adjust version of pydocstile to return detailed errors to the test."""
    log.setLevel(logging.DEBUG)
    conf = ConfigurationParser()
    setup_stream_handlers(conf.get_default_run_configuration())

    try:
        conf.parse()
    except IllegalConfiguration:
        return ReturnCode.invalid_options

    run_conf = conf.get_user_run_configuration()

    # Reset the logger according to the command line arguments
    setup_stream_handlers(run_conf)

    log.debug("starting in debug mode.")

    Error.explain = run_conf.explain
    Error.source = run_conf.source
github pymedphys / pymedphys / app / packages / pyodide-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))