How to use pep8 - 10 common examples

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 puentesarrin / bonzo / tests / runtests.py View on Github external
try:
        import pep8
        has_pep8 = True
    except ImportError:
        if options.with_pep8:
            sys.stderr.write('# Could not find pep8 library.')
            sys.exit(1)

    if has_pep8:
        guide_main = pep8.StyleGuide(
            ignore=[],
            paths=['bonzo/'],
            exclude=[],
            max_line_length=80,
        )
        guide_tests = pep8.StyleGuide(
            ignore=['E221'],
            paths=['tests/'],
            max_line_length=80,
        )
        for guide in (guide_main, guide_tests):
            report = guide.check_files()
            if report.total_errors:
                sys.exit(1)

    suite = make_suite('', tuple(extra_args), options.force_all)

    runner = TextTestRunner(verbosity=options.verbosity - options.quietness + 1)
    result = runner.run(suite)
    sys.exit(not result.wasSuccessful())
github magenta-aps / bibos_admin / admin_site / system / tests.py View on Github external
def do_test(self):
        arglist = ['--exclude=migrations', filepath]
        pep8.process_options(arglist)

        pep8.input_dir(filepath)
        output = pep8.get_statistics()
        # print "PEP8 OUTPUT: " + str(output)
        self.assertEqual(len(output), 0)
github mysql / mysql-utilities / support / pylint_tests.py View on Github external
_CURRENT_PATH = os.path.abspath(os.path.dirname(__file__))
(_BASE_PATH, _,) = os.path.split(_CURRENT_PATH)

if os.path.exists(os.path.join(_BASE_PATH, "internal")):
    _PACKAGES = _PACKAGES + (os.path.join("internal", "packaging"),)

# Add base path and mysql-test to sys.path
sys.path.append(_BASE_PATH)
sys.path.append(os.path.join(_BASE_PATH, "mysql-test", "mutlib"))

if pylint_version.split(".") < _PYLINT_MIN_VERSION.split("."):
    sys.stdout.write("ERROR: pylint version >= {0} is required to run "
                     "pylint_tests.\n".format(_PYLINT_MIN_VERSION))
    sys.exit(1)

if pep8_version.split(".") < _PEP8_MIN_VERSION.split("."):
    sys.stdout.write("ERROR: pep8 version >= {0} is required to run "
                     "pylint_tests.\n".format(_PEP8_MIN_VERSION))
    sys.exit(1)


class CustomTextReporter(TextReporter):
    """A reporter similar to TextReporter, but display messages in a custom
    format.
    """
    name = "custom"
    line_format = "{msg_id}:{line:4d},{column:2d}: {msg}"


class ParseableTextReporter(TextReporter):
    """A reporter very similar to TextReporter, but display messages in a form
    recognized by most text editors.
github mkouhei / backup2swift / src / backup2swift_tests / test_pep8.py View on Github external
def test_pep8():
        if pep8.__version__ >= '1.3':
            arglist = [['statistics', True],
                       ['show-source', True],
                       ['repeat', True],
                       ['exclude', []],
                       ['paths', [BASE_DIR]]]

            pep8style = pep8.StyleGuide(arglist,
                                        parse_argv=False,
                                        config_file=True)
            options = pep8style.options
            if options.doctest:
                import doctest
                fail_d, done_d = doctest.testmod(report=False,
                                                 verbose=options.verbose)
                fail_s, done_s = selftest(options)
                count_failed = fail_s + fail_d
github dssg / ushine-learning / test / test_pep8.py View on Github external
def test_pep8(self):
        basepath = os.getcwd()
        print 'Running PEP-8 checks on path', basepath
        path_list = [basepath + '/dssg', basepath + '/test']
        pep8style = pep8.StyleGuide(paths=path_list, ignore=['E128', 'E501'])
        report = pep8style.check_files()
        if report.total_errors:
            print report.total_errors

        self.assertEqual(
            report.total_errors, 0, 'Codebase does not pass PEP-8')
github ch3pjw / junction / test / test_pep8.py View on Github external
def test_pep8_conformance(self):
        cur_dir_path = os.path.dirname(__file__)
        root_path = os.path.join(cur_dir_path, os.pardir)
        config_path = os.path.join(cur_dir_path, 'pep8_config')
        pep8_style = pep8.StyleGuide(
            paths=[root_path],
            config_file=config_path)
        result = pep8_style.check_files()
        self.assertEqual(
            result.total_errors, 0,
            'Found {:d} code style errors/warnings in {}!'.format(
                result.total_errors, root_path))
github skorokithakis / jsane / tests / test_jsane.py View on Github external
def test_pep8(self):
        pep8style = pep8.StyleGuide([['statistics', True],
                                     ['show-sources', True],
                                     ['repeat', True],
                                     ['ignore', "E501"],
                                     ['paths', [os.path.dirname(
                                         os.path.abspath(__file__))]]],
                                    parse_argv=False)
        report = pep8style.check_files()
        assert report.total_errors == 0
github gccxml / pygccxml / unittests / pep8_tester.py View on Github external
def run_check(self, path):
        """Common method to run the pep8 test."""

        pep8style = pep8.StyleGuide()
        result = pep8style.check_files(paths=[path])

        if result.total_errors != 0:
            self.assertEqual(
                result.total_errors, 0,
                "Found code style errors (and warnings).")
github datawrestler / after-hours / after_hours_unittests.py View on Github external
def test_pep8(self):
        self.pep8style = pep8.StyleGuide(show_source=True)
        files = ('after_hours.py', 'after_hours_unittests.py')
        self.pep8style.check_files(files)
        self.assertEqual(self.pep8style.options.report.total_errors, 0)
github moinwiki / moin-1.9 / MoinMoin / _tests / test_sourcecode.py View on Github external
def pep8_error_count(path):
    # process_options initializes some data structures and MUST be called before each Checker().check_all()
    pep8.process_options(['pep8', '--ignore=E202,E221,E222,E241,E301,E302,E401,E501,E701,W391,W601,W602', '--show-source', 'dummy_path'])
    error_count = pep8.Checker(path).check_all()
    return error_count