From 61e24cfbeafe2bfcf540ed8f9fa6cb4545fd35c3 Mon Sep 17 00:00:00 2001 From: Tommy Ip Date: Thu, 6 Jul 2017 13:01:43 +0800 Subject: [PATCH] tools: Remove unused `bright_red_output` context manager. This context manager is no longer in use since the linter visual updates. --- tools/lint | 82 ++++++++++++++++++++++-------------------------------- 1 file changed, 34 insertions(+), 48 deletions(-) diff --git a/tools/lint b/tools/lint index e17ec1722c..30b5d57ec9 100755 --- a/tools/lint +++ b/tools/lint @@ -1,7 +1,6 @@ #!/usr/bin/env python from __future__ import print_function from __future__ import absolute_import -from contextlib import contextmanager import logging import os import sys @@ -17,18 +16,6 @@ sanity_check.check_venv(__file__) import lister from typing import cast, Callable, Dict, Iterator, List -@contextmanager -def bright_red_output(): - # type: () -> Iterator[None] - # Make the lint output bright red - sys.stdout.write('\x1B[1;31m') - sys.stdout.flush() - try: - yield - finally: - # Restore normal terminal colors - sys.stdout.write('\x1B[0m') - def run_parallel(lint_functions): # type: (Dict[str, Callable[[], int]]) -> bool @@ -155,47 +142,46 @@ def run(): lint_functions[name] = run_linter - with bright_red_output(): - external_linter('add_class', ['tools/find-add-class']) - external_linter('css', ['tools/check-css'], ['css']) - external_linter('eslint', ['node', 'node_modules/.bin/eslint', '--quiet'], ['js']) - external_linter('tslint', ['node', 'node_modules/.bin/tslint', '-c', - 'static/ts/tslint.json'], ['ts']) - external_linter('puppet', ['puppet', 'parser', 'validate'], ['pp']) - external_linter('templates', ['tools/check-templates'], ['handlebars', 'html']) - external_linter('urls', ['tools/check-urls']) - external_linter('swagger', ['node', 'tools/check-swagger'], ['yaml']) + external_linter('add_class', ['tools/find-add-class']) + external_linter('css', ['tools/check-css'], ['css']) + external_linter('eslint', ['node', 'node_modules/.bin/eslint', '--quiet'], ['js']) + external_linter('tslint', ['node', 'node_modules/.bin/tslint', '-c', + 'static/ts/tslint.json'], ['ts']) + external_linter('puppet', ['puppet', 'parser', 'validate'], ['pp']) + external_linter('templates', ['tools/check-templates'], ['handlebars', 'html']) + external_linter('urls', ['tools/check-urls']) + external_linter('swagger', ['node', 'tools/check-swagger'], ['yaml']) - # gitlint disabled until we can stabilize it more -# if not options.no_gitlint: -# external_linter('commit_messages', ['tools/commit-message-lint']) + # gitlint disabled until we can stabilize it more + # if not options.no_gitlint: + # external_linter('commit_messages', ['tools/commit-message-lint']) + @lint + def custom_py(): + # type: () -> int + failed = check_custom_checks_py() + return 1 if failed else 0 + + @lint + def custom_nonpy(): + # type: () -> int + failed = check_custom_checks_nonpy() + return 1 if failed else 0 + + @lint + def pyflakes(): + # type: () -> int + failed = check_pyflakes(options, by_lang) + return 1 if failed else 0 + + if options.pep8: @lint - def custom_py(): + def pep8(): # type: () -> int - failed = check_custom_checks_py() + failed = check_pep8(by_lang['py']) return 1 if failed else 0 - @lint - def custom_nonpy(): - # type: () -> int - failed = check_custom_checks_nonpy() - return 1 if failed else 0 - - @lint - def pyflakes(): - # type: () -> int - failed = check_pyflakes(options, by_lang) - return 1 if failed else 0 - - if options.pep8: - @lint - def pep8(): - # type: () -> int - failed = check_pep8(by_lang['py']) - return 1 if failed else 0 - - failed = run_parallel(lint_functions) + failed = run_parallel(lint_functions) sys.exit(1 if failed else 0)