commit de509f99145f8a50873210e075220c3697a40418 Author: Akihiro Motoki Date: Thu Sep 10 14:45:51 2020 +0900 Follow-up on pylint upgrade * Adds comments on pylint disabled checks * Enable 'deprecated-method' check. We have no failures now. * Convert global disabled checks 'no-value-for-parameter' and 'using-constant-test' to per-comment disables. Other cleanup would be larger and/or better to be visited separately. Change-Id: Id47dc8de4abcc8c744d96d2accf3a2a09ae206d4 diff --git a/.pylintrc b/.pylintrc index c31bb4c..071d52d 100644 --- a/.pylintrc +++ b/.pylintrc @@ -12,18 +12,18 @@ disable= # "E" Error for important programming issues (likely bugs) method-hidden, no-member, - no-value-for-parameter, # TODO not-callable, # "W" Warnings for stylistic problems or minor programming issues arguments-differ, attribute-defined-outside-init, bad-indentation, broad-except, - deprecated-method, # TODO fixme, + # python3 way: pylint suggests to follow PEP 3102 keyword-arg-before-vararg, # TODO pointless-string-statement, protected-access, + # We should do it carefully considering PEP3134 raise-missing-from, # TODO redefined-builtin, redefined-outer-name, @@ -33,7 +33,6 @@ disable= unused-argument, unused-wildcard-import, useless-else-on-loop, - using-constant-test, # TODO wildcard-import, # "C" Coding convention violations abstract-method, @@ -42,21 +41,27 @@ disable= bad-continuation, deprecated-lambda, global-statement, + # Not a good idea to disable this globally + # Check one by one and add pylint disabled comment if needed import-outside-toplevel, # TODO invalid-name, missing-docstring, superfluous-parens, too-many-lines, unused-variable, - wrong-import-order, # TODO + # import order is checked by flake8 (and pylint rule is incompatible with it) + wrong-import-order, # "R" Refactor recommendations duplicate-code, inconsistent-return-statements, # TODO interface-not-implemented, + # Better to be fixed but too many hits :( no-else-continue, # TODO + # Better to be fixed but too many hits :( no-else-raise, # TODO no-else-return, no-self-use, + # python3 way: Let's do it once we have a consensus. super-with-arguments, # TODO too-many-ancestors, too-many-arguments, @@ -66,6 +71,7 @@ disable= too-many-locals, too-many-return-statements, too-many-statements, + # Better to be fixed but too many hits :( unnecessary-comprehension, # TODO useless-object-inheritance diff --git a/horizon/exceptions.py b/horizon/exceptions.py index c2cf004..576cc51 100644 --- a/horizon/exceptions.py +++ b/horizon/exceptions.py @@ -340,6 +340,8 @@ def handle(request, message=None, redirect=None, ignore=False, exc_handler.get('escalate', escalate), handled, force_silence, force_log, log_method, log_entry, log_level) + # NOTE: pylint seems to get confused :( + # pylint: disable=using-constant-test if ret: return ret # return to normal code flow @@ -353,6 +355,7 @@ def handle(request, message=None, redirect=None, ignore=False, ret = handle_recoverable(request, user_message, redirect, ignore, escalate, handled, force_silence, force_log, log_method, log_entry, log_level) + # NOTE: pylint seems to get confused :( # pylint: disable=using-constant-test if ret: return ret diff --git a/horizon/forms/views.py b/horizon/forms/views.py index 319b281..ba61131 100644 --- a/horizon/forms/views.py +++ b/horizon/forms/views.py @@ -64,6 +64,8 @@ class ModalFormMixin(ModalBackdropMixin): # Transform standard template name to ajax name (leading "_") bits = list(os.path.split(self.template_name)) bits[1] = "".join(("_", bits[1])) + # NOTE: Looks like false-positive in pylint 2.6.0 + # pylint: disable=no-value-for-parameter self.ajax_template_name = os.path.join(*bits) template = self.ajax_template_name else: