Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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()
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))
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))
def report_error(self, line_number, offset, text, check):
return pep8.Checker.report_error(
self, line_number, offset, text, check)
def report_error(self, line_number, offset, text, check):
return pep8.Checker.report_error(
self, line_number, offset, text, check)