How to use the pydocstyle.PEP257Checker 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 dreadatour / Flake8Lint / lint.py View on Github external
def lint(lines, settings):
    """Run flake8 lint with internal interpreter."""
    warnings = []

    # lint with pep8
    if settings.get('pep8', True):
        pep8style = pep8.StyleGuide(
            reporter=Pep8Report,
            ignore=['DIRTY-HACK'],  # PEP8 error will never starts like this
            max_line_length=settings.get('pep8_max_line_length')
        )
        pep8style.input_file(filename=None, lines=lines.splitlines(True))
        warnings.extend(pep8style.options.report.errors)

    if settings.get('pydocstyle', False):
        for error in PEP257Checker().check_source(lines, ''):
            warnings.append((
                getattr(error, 'line', 0),
                0,
                getattr(error, 'message', '')
            ))

    try:
        tree = compile(lines, '', 'exec', ast.PyCF_ONLY_AST, True)
    except (SyntaxError, TypeError):
        (exc_type, exc) = sys.exc_info()[:2]
        if len(exc.args) > 1:
            offset = exc.args[1]
            if len(offset) > 2:
                offset = offset[1:3]
        else:
            offset = (1, 0)