How to use the pep8.Checker.report_error function in pep8

To help you get started, we’ve selected a few pep8 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 douglas / sublimetext2_configs / sublimelint / modules / python.py View on Github external
def pep8_check(code, filename, ignore=None):
    messages = []

    _lines = code.split('\n')
    if _lines:
        def report_error(self, line_number, offset, text, check):
            code = text[:4]
            msg = text[5:]
            if pep8.ignore_code(code):
                return
            if code.startswith('E'):
                messages.append(Pep8Error(filename, Dict2Obj(lineno=line_number, col_offset=offset), code, msg))
            else:
                messages.append(Pep8Warning(filename, Dict2Obj(lineno=line_number, col_offset=offset), code, msg))
        pep8.Checker.report_error = report_error

        _ignore = ignore + pep8.DEFAULT_IGNORE.split(',')
        class FakeOptions:
            verbose = 0
            select = []
            ignore = _ignore
        pep8.options = FakeOptions()
        pep8.options.physical_checks = pep8.find_checks('physical_line')
        pep8.options.logical_checks = pep8.find_checks('logical_line')
        pep8.options.counters = dict.fromkeys(pep8.BENCHMARK_KEYS, 0)
        good_lines = [l + '\n' for l in _lines]
        good_lines[-1] = good_lines[-1].rstrip('\n')
        if not good_lines[-1]:
            good_lines = good_lines[:-1]
        try:
            pep8.Checker(filename, good_lines).check_all()
github kivy / kivy-designer / tools / pep8checker / pep8kivy.py View on Github external
def report_error(self, line_number, offset, text, check):
        if htmlmode is False:
            return pep8.Checker.report_error(self,
                line_number, offset, text, check)

        # html generation
        print('{0}{1}'.format(line_number, text))
github kivy / plyer / plyer / tools / pep8checker / pep8kivy.py View on Github external
def report_error(self, line_number, offset, text, check):
        if htmlmode is False:
            return pep8.Checker.report_error(self,
                line_number, offset, text, check)

        # html generation
        print('{0}{1}'.format(line_number, text))
github pyKy / kivy-doc-ja / kivy / tools / pep8checker / pep8kivy.py View on Github external
def report_error(self, line_number, offset, text, check):
        return pep8.Checker.report_error(
            self, line_number, offset, text, check)
github kivy / kivy / kivy / tools / pep8checker / pep8kivy.py View on Github external
def report_error(self, line_number, offset, text, check):
        return pep8.Checker.report_error(
            self, line_number, offset, text, check)