mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-05 19:46:54 +00:00
Added loaderon-hooks logic
This commit is contained in:
parent
0b70e285e3
commit
0a66e6635d
23 changed files with 612 additions and 0 deletions
|
|
@ -0,0 +1,28 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
|
||||
from pre_commit_logic.util.template_methods.lines_checker_template_method import LinesCheckerTemplateMethod
|
||||
|
||||
|
||||
class ClassDocstringChecker(LinesCheckerTemplateMethod):
|
||||
def _check_line(self):
|
||||
regular_expression = r'^(\t| )*class .+\(.*\):'
|
||||
pattern = re.compile(regular_expression)
|
||||
if pattern.match(self._file_line):
|
||||
self.__check_class_docstring(self._file_line_index)
|
||||
|
||||
def __check_class_docstring(self, class_line_index):
|
||||
class_first_line = self._file_lines[class_line_index + 1]
|
||||
if class_first_line in ['\n', '\r\n']:
|
||||
self.inform_check_failure('El docstring de la clase {} está separado de su clase por una o más líneas en '
|
||||
'blanco.'.format(self._file_lines[class_line_index]))
|
||||
if not class_first_line.strip().startswith('\"\"\"'):
|
||||
self.inform_check_failure('La clase {} no tiene docstring.'.format(self._file_lines[class_line_index]))
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
return ClassDocstringChecker(argv).run()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
exit(main())
|
||||
Loading…
Add table
Add a link
Reference in a new issue