How to use the flake8.api.legacy function in flake8

To help you get started, we’ve selected a few flake8 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 Devoxin / Lavalink.py / run_tests.py View on Github external
def test_flake8():
    style_guide = legacy.get_style_guide()
    report = style_guide.check_files(['lavalink'])
    statistics = report.get_statistics('E')

    if not statistics:
        print('OK')
github Edurate / edurate / tests / test_edurate.py View on Github external
def test_flake8():

    # list of all file names to be checked for PEP8
    filenames = list()

    # fill list with all python files found in all subdirectories
    for root, dirs, files in os.walk("edurate", topdown=False):
        pyFiles = glob.glob(root + "/*.py")
        filenames.extend(pyFiles)

    style_guide = flake8.get_style_guide(ignore=["E265", "E501", "F405", "F812", "E402"])
    report = style_guide.check_files(filenames)
    assert report.get_statistics('E') == [], 'Flake8 found violations'
github GatorIncubator / gatorgrouper / tests / test_flake8.py View on Github external
def test_flake8():

    # list of all file names to be checked for PEP8
    filenames = list()

    # fill list with all python files found in all subdirectories
    for root, dirs, files in os.walk("gatorgrouper", topdown=False):
        pyFiles = glob.glob(root + "/*.py")
        filenames.extend(pyFiles)

    style_guide = flake8.get_style_guide(ignore=["E265", "E501"])
    report = style_guide.check_files(filenames)
    assert report.get_statistics('E') == [], 'Flake8 found violations'
github xhochy / fletcher / tests / test_codestyle.py View on Github external
def test_codestyle():
    basedir = os.path.dirname(__file__)

    style_guide = flake8.get_style_guide(max_line_length=88)
    report = style_guide.check_files(
        glob.glob(os.path.abspath(os.path.join(basedir, "*.py")))
        + glob.glob(os.path.abspath(os.path.join(basedir, "..", "fletcher", "*.py")))
        + glob.glob(os.path.abspath(os.path.join(basedir, "..", "benchmarks", "*.py")))
    )

    assert report.total_errors == 0
github computational-seismology / pytomo3d / tests / test_code_formatting.py View on Github external
ignore = False
        for path in ignore_paths:
            if dirpath.startswith(path):
                ignore = True
                break
        if ignore:
            continue
        filenames = [_i for _i in filenames if
                     os.path.splitext(_i)[-1] == os.path.extsep + "py"]
        if not filenames:
            continue
        for py_file in filenames:
            full_path = os.path.join(dirpath, py_file)
            files.append(full_path)

    style_guide = flake8.get_style_guide(ignore=['E24', 'W503', 'E226'])
    report = style_guide.check_files(files)
    assert report.get_statistics('E') == [], 'Flake8 found violations'
    assert report.total_errors == 0
github PyCQA / flake8 / tests / unit / test_legacy_api.py View on Github external
def test_styleguide_options():
    """Show tha we proxy the StyleGuide.options attribute."""
    app = mock.Mock()
    app.options = 'options'
    style_guide = api.StyleGuide(app)
    assert style_guide.options == 'options'
github beeware / briefcase-template / tests / test_app_template.py View on Github external
def test_flake8_app(app_directory, args):
    """Check there are no flake8 errors in any of the generated python files"""
    files = [f for f in _all_filenames(app_directory) if f.endswith(".py")]
    style_guide = flake8.get_style_guide()
    report = style_guide.check_files(files)
    assert report.get_statistics("E") == [], "Flake8 found violations"
github Edurate / edurate / tests / test_dictionary_create.py View on Github external
def test_flake8():

    # list of all file names to be checked for PEP8
    filenames = list()

    # fill list with all python files found in all subdirectories
    for root, dirs, files in os.walk("edurate", topdown=False):
        pyFiles = glob.glob(root + "/*.py")
        filenames.extend(pyFiles)

    style_guide = flake8.get_style_guide(ignore=["E265", "E501", "F405"])
    report = style_guide.check_files(filenames)
    assert report.get_statistics('E') == [], 'Flake8 found violations'
github fsr-de / 1327 / _1327 / main / management / commands / lint.py View on Github external
def handle(self, *args, **options):
		os.chdir(os.path.join(os.path.join(BASE_DIR, '..')))
		style = flake8.get_style_guide(config_file='.flake8')
		report = style.check_files(['_1327'])
		if report.total_errors > 0:
			sys.exit(1)
github deathbeds / lintotype / packages / ipylintotype / src / ipylintotype / diagnosers / flake8_diagnoser.py View on Github external
self,
        cell_id: typ.Text,
        code: typ.List[shapes.Cell],
        metadata: typ.Dict[str, typ.Dict[str, typ.Any]],
        shell: InteractiveShell,
        *args,
        **kwargs
    ) -> shapes.Annotations:
        code_str, line_offsets = self.transform_for_diagnostics(code, shell)

        out = io.StringIO()
        with contextlib.redirect_stdout(out):
            file = tempfile.NamedTemporaryFile(delete=False)
            file.write(code_str.encode("utf-8"))
            file.close()
            style_guide = legacy.get_style_guide(ignore=self.ignore, select=self.select)
            report = style_guide.check_files([file.name])
            os.unlink(file.name)

        matches = re.findall(_re_flake8, out.getvalue(), flags=re.M)

        diagnostics: typ.List[shapes.Diagnostic] = []
        for file, line, col, err_code, msg in matches:
            line = int(line) - line_offsets[cell_id]
            col = int(col)
            diagnostics.append(
                {
                    "message": msg,
                    "source": self.entry_point,
                    "severity": self.Severity.error,
                    "code": err_code,
                    "range": {