Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def execute(self):
"""Check the code with pep257 to find errors
"""
errors = []
try:
for error in pydocstyle.ConventionChecker().check_source(
self.code, self.filename
):
error_code = getattr(error, 'code', None)
if error_code is not None and error_code not in self.ignore: # noqa
errors.append(self._convert(error))
except Exception as error:
print(error)
return errors
:return list: List of errors.
"""
if 'ignore_decorators' in params:
ignore_decorators = params['ignore_decorators']
else:
ignore_decorators = None
check_source_args = (code, path, ignore_decorators) if THIRD_ARG else (code, path)
return [{
'lnum': e.line,
# Remove colon after error code ("D403: ..." => "D403 ...").
'text': (e.message[0:4] + e.message[5:]
if e.message[4] == ':' else e.message),
'type': 'D',
'number': e.code
} for e in PyDocChecker().check_source(*check_source_args)]
def __init__(self, tree, filename, lines):
"""Initialize the checker."""
self.tree = tree
self.filename = filename
self.checker = pep257.ConventionChecker()
self.source = ''.join(lines)