From e915d532a6b1a4c7ade1463124be74107c3a765c Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 25 Feb 2019 21:39:42 +0100 Subject: [PATCH] Silence pylint Silence pylint in specific places where we're doing slightly unusual or dodgy, but correct. --- scripts/abi_check.py | 4 +++- tests/scripts/generate_test_code.py | 2 +- tests/scripts/mbedtls_test.py | 3 ++- tests/scripts/test_generate_test_code.py | 4 +++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/abi_check.py b/scripts/abi_check.py index 88435ef02..7926bc8cd 100755 --- a/scripts/abi_check.py +++ b/scripts/abi_check.py @@ -268,7 +268,9 @@ def run_main(): ) return_code = abi_check.check_for_abi_changes() sys.exit(return_code) - except Exception: + except Exception: # pylint: disable=broad-except + # Print the backtrace and exit explicitly so as to exit with + # status 2, not 1. traceback.print_exc() sys.exit(2) diff --git a/tests/scripts/generate_test_code.py b/tests/scripts/generate_test_code.py index 125802442..1fff09992 100755 --- a/tests/scripts/generate_test_code.py +++ b/tests/scripts/generate_test_code.py @@ -238,7 +238,7 @@ class FileWrapper(io.FileIO, object): if hasattr(parent, '__next__'): line = parent.__next__() # Python 3 else: - line = parent.next() # Python 2 + line = parent.next() # Python 2 # pylint: disable=no-member if line is not None: self._line_no += 1 # Convert byte array to string with correct encoding and diff --git a/tests/scripts/mbedtls_test.py b/tests/scripts/mbedtls_test.py index c7027659f..ac2912d4c 100755 --- a/tests/scripts/mbedtls_test.py +++ b/tests/scripts/mbedtls_test.py @@ -37,7 +37,8 @@ https://github.com/ARMmbed/greentea import re import os import binascii -from mbed_host_tests import BaseHostTest, event_callback + +from mbed_host_tests import BaseHostTest, event_callback # pylint: disable=import-error class TestDataParserError(Exception): diff --git a/tests/scripts/test_generate_test_code.py b/tests/scripts/test_generate_test_code.py index 2ef12e18d..6d7113e18 100755 --- a/tests/scripts/test_generate_test_code.py +++ b/tests/scripts/test_generate_test_code.py @@ -22,7 +22,7 @@ Unit tests for generate_test_code.py """ - +# pylint: disable=wrong-import-order try: # Python 2 from StringIO import StringIO @@ -36,6 +36,7 @@ try: except ImportError: # Python 3 from unittest.mock import patch +# pylint: enable=wrong-import-order from generate_test_code import gen_dependencies, gen_dependencies_one_line from generate_test_code import gen_function_wrapper, gen_dispatch from generate_test_code import parse_until_pattern, GeneratorInputError @@ -336,6 +337,7 @@ class StringIOWrapper(StringIO, object): :param length: :return: """ + # pylint: disable=unused-argument line = super(StringIOWrapper, self).readline() if line is not None: self.line_no += 1