How to use the pydocstyle.check 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 runtest(self):
        pydocstyle.utils.log.setLevel(logging.WARN)  # TODO: follow that of pytest

        # https://github.com/PyCQA/pydocstyle/blob/4.0.1/src/pydocstyle/cli.py#L42-L45
        for filename, checked_codes, ignore_decorators in self.parser.get_files_to_check():
            errors = [str(error) for error in pydocstyle.check((str(self.fspath),), select=checked_codes,
                                                               ignore_decorators=ignore_decorators)]
        if errors:
            raise PyDocStyleError('\n'.join(errors))
        elif hasattr(self.config, 'cache'):
            # update cache
            # http://pythonhosted.org/pytest-cache/api.html
            cache = self.config.cache.get(self.CACHE_KEY, {})
            cache[str(self.fspath)] = self.fspath.mtime()
            self.config.cache.set(self.CACHE_KEY, cache)
github CheckPointSW / Karta / tests.py View on Github external
import pydocstyle
import os
from glob import glob

SRC_DIR = "src"

def fileList():
    return filter(lambda z: not z.endswith("__init__.py"), [y for x in os.walk(SRC_DIR) for y in glob(os.path.join(x[0], '*.py'))])


file_list = fileList()

passed = True

# Documentation tests
for check in pydocstyle.check(file_list, ignore=["D100", "D104", "D413", "D213", "D203", "D402"]):
    print(check)
    passed = False

# last status
exit(0 if passed else 1)
github dickreuter / neuron_poker / tests / test_pylint.py View on Github external
log.debug("starting in debug mode.")

    Error.explain = run_conf.explain
    Error.source = run_conf.source

    errors = []
    changed_files = get_relevant_files()

    if not changed_files:
        return []

    all_files = conf.get_files_to_check()
    all_files = [file for file in all_files if file[0] in changed_files]
    try:
        for filename, checked_codes, ignore_decorators in all_files:
            errors.extend(check((filename,), select=checked_codes, ignore_decorators=ignore_decorators))
    except IllegalConfiguration as error:
        # An illegal configuration file was found during file generation.
        log.error(error.args[0])
        return ReturnCode.invalid_options

    count = 0
    errors_final = []
    for err in errors:
        if hasattr(err, 'code') and not any(ignore in str(err) for ignore in IGNORES):
            sys.stdout.write('%s\n' % err)
            errors_final.append(err)
        count += 1
    return errors_final
github jayclassless / tidypy / src / tidypy / tools / pydocstyle.py View on Github external
def execute(self, finder):
        issues = []

        logging.disable(logging.CRITICAL)

        for filepath in finder.files(self.config['filters']):
            issues += [
                self.make_issue(error, filepath)
                for error in check(
                    (filepath,),
                    ignore=self.config['disabled'],
                )
            ]

        logging.disable(logging.NOTSET)

        return issues