def test_flake8(): # for some reason the pydocstyle logger changes to an effective level of 1 # set higher level to prevent the output to be flooded with debug messages log.setLevel(logging.WARN) style_guide = get_style_guide( extend_ignore=['D100', 'D104'], show_source=True, ) style_guide_tests = get_style_guide( extend_ignore=['D100', 'D101', 'D102', 'D103', 'D104', 'D105', 'D107'], show_source=True, ) stdout = sys.stdout sys.stdout = sys.stderr # implicitly calls report_errors() report = style_guide.check_files([ str(Path(__file__).parents[1] / 'bin' / 'colcon'), str(Path(__file__).parents[1] / 'colcon_core'), ]) report_tests = style_guide_tests.check_files([ str(Path(__file__).parents[1] / 'test'), ]) sys.stdout = stdout total_errors = report.total_errors + report_tests.total_errors if total_errors: # pragma: no cover # output summary with per-category counts print() if report.total_errors: report._application.formatter.show_statistics(report._stats) if report_tests.total_errors: report_tests._application.formatter.show_statistics( report_tests._stats) print('flake8 reported {total_errors} errors'.format_map(locals()), file=sys.stderr) assert not total_errors, \ 'flake8 reported {total_errors} errors'.format_map(locals())
from xml.sax.saxutils import escape from xml.sax.saxutils import quoteattr import pydocstyle from pydocstyle import check try: # as of version 1.1.0 from pydocstyle.config import ConfigurationParser from pydocstyle.violations import Error from pydocstyle.utils import log except ImportError: # try version 1.0.0 from pydocstyle import ConfigurationParser from pydocstyle import Error from pydocstyle import log log.setLevel(logging.INFO) _conventions = set(pydocstyle.conventions.keys()) _conventions.add('ament') _ament_ignore = [ 'D100', 'D101', 'D102', 'D103', 'D104', 'D105', 'D106', 'D107', 'D203', 'D212',
import time from xml.sax.saxutils import escape from xml.sax.saxutils import quoteattr from pydocstyle import check try: # as of version 1.1.0 from pydocstyle.config import ConfigurationParser from pydocstyle.violations import Error from pydocstyle.utils import log except ImportError: # try version 1.0.0 from pydocstyle import ConfigurationParser from pydocstyle import Error from pydocstyle import log log.setLevel(logging.INFO) def main(argv=sys.argv[1:]): parser = argparse.ArgumentParser( description='Check docstrings against the style conventions in PEP 257.', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument( '--ignore', nargs='*', default=['D100', 'D101', 'D102', 'D103', 'D104', 'D105', 'D203', 'D212', 'D404'], help='The pep257 categories to ignore') parser.add_argument( 'paths', nargs='*', default=[os.curdir],