Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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')
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'
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'
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
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
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'
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"
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'
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)
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": {