From f88750d66512bb01fa64e9080f3d3fbc9eb9d758 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Sat, 9 Sep 2017 08:59:09 -0700 Subject: [PATCH] Expand disabled pylint rules. (#29162) * Expand disabled pylint rules. * Fix pylint and unicode issues in ansible-test. --- test/runner/lib/sanity/pylint.py | 2 +- test/runner/lib/test.py | 2 +- test/runner/lib/util.py | 3 ++ test/sanity/pylint/disable.txt | 88 +++++++++++++++++++++++++++++--- test/sanity/pylint/enable.txt | 1 - 5 files changed, 87 insertions(+), 9 deletions(-) diff --git a/test/runner/lib/sanity/pylint.py b/test/runner/lib/sanity/pylint.py index d8659d230c7..45347a09e32 100644 --- a/test/runner/lib/sanity/pylint.py +++ b/test/runner/lib/sanity/pylint.py @@ -89,7 +89,7 @@ class PylintTest(SanitySingleVersion): messages = [] errors = [SanityMessage( - message=m['message'], + message=m['message'].replace('\n', ' '), path=m['path'], line=int(m['line']), column=int(m['column']), diff --git a/test/runner/lib/test.py b/test/runner/lib/test.py index 0e163a99f9f..967f1d842bd 100644 --- a/test/runner/lib/test.py +++ b/test/runner/lib/test.py @@ -359,7 +359,7 @@ class TestFailure(TestResult): if self.summary: block = self.summary else: - block = '\n'.join(str(m) for m in self.messages) + block = '\n'.join(m.format() for m in self.messages) message = block.strip() diff --git a/test/runner/lib/util.py b/test/runner/lib/util.py index 8d58d4843cf..20da394ede6 100644 --- a/test/runner/lib/util.py +++ b/test/runner/lib/util.py @@ -374,6 +374,9 @@ class Display(object): message = message.replace(self.clear, color) message = '%s%s%s' % (color, message, self.clear) + if sys.version_info[0] == 2 and isinstance(message, type(u'')): + message = message.encode('utf-8') + print(message, file=fd) fd.flush() diff --git a/test/sanity/pylint/disable.txt b/test/sanity/pylint/disable.txt index 87776ef5246..8bc2fae97d2 100644 --- a/test/sanity/pylint/disable.txt +++ b/test/sanity/pylint/disable.txt @@ -1,24 +1,100 @@ +abstract-method access-member-before-definition +anomalous-backslash-in-string +anomalous-unicode-escape-in-string +arguments-differ assignment-from-no-return -C +attribute-defined-outside-init +bad-continuation +bad-format-string +bad-indentation +bad-mcs-classmethod-argument +bad-open-mode +bad-whitespace +bare-except +blacklisted-name +broad-except +cell-var-from-loop +consider-iterating-dictionary +consider-using-enumerate +dangerous-default-value +deprecated-method +deprecated-module +duplicate-key +eval-used +exec-used +expression-not-assigned +fixme function-redefined +global-at-module-level +global-statement +global-variable-not-assigned +global-variable-undefined import-error +import-self +invalid-name +line-too-long locally-disabled -locally-enabled +logging-format-interpolation +logging-not-lazy +lost-exception method-hidden +misplaced-comparison-constant +missing-docstring no-member +no-name-in-module +no-self-use no-value-for-parameter non-iterator-returned -no-name-in-module not-a-mapping not-an-iterable not-callable -R +pointless-statement +pointless-string-statement +protected-access raising-bad-type -raising-non-exception +redefined-builtin +redefined-outer-name +redefined-variable-type +redundant-unittest-assert +reimported +signature-differs +simplifiable-if-statement +super-init-not-called +superfluous-parens +suppressed-message +too-few-public-methods +too-many-ancestors +too-many-arguments +too-many-boolean-expressions +too-many-branches too-many-function-args +too-many-instance-attributes +too-many-lines +too-many-locals +too-many-nested-blocks +too-many-public-methods +too-many-return-statements +too-many-statements +trailing-newlines +undefined-loop-variable unexpected-keyword-arg +ungrouped-imports +unidiomatic-typecheck +unnecessary-lambda +unnecessary-pass +unneeded-not +unreachable unsubscriptable-object unsupported-membership-test +unused-argument +unused-import +unused-variable +unused-wildcard-import used-before-assignment -W +useless-else-on-loop +useless-suppression +using-constant-test +wildcard-import +wrong-import-order +wrong-import-position diff --git a/test/sanity/pylint/enable.txt b/test/sanity/pylint/enable.txt index 224cd8b175b..e69de29bb2d 100644 --- a/test/sanity/pylint/enable.txt +++ b/test/sanity/pylint/enable.txt @@ -1 +0,0 @@ -#wildcard-import