Commit 0d09fce2 authored by Jérome Perrin's avatar Jérome Perrin

pylint: dummy plugin to ignore messages on python2

parent 0e3ee9e6
...@@ -554,6 +554,7 @@ def checkPythonSourceCode(source_code_str, portal_type=None): ...@@ -554,6 +554,7 @@ def checkPythonSourceCode(source_code_str, portal_type=None):
args.extend( args.extend(
( (
"--msg-template='{C}: {line},{column}: {msg} ({symbol})'", "--msg-template='{C}: {line},{column}: {msg} ({symbol})'",
'--load-plugins=pylint.extensions.bad_builtin',
# BBB until we drop compatibility with PY2 # BBB until we drop compatibility with PY2
'--disable=redundant-u-string-prefix,raise-missing-from,keyword-arg-before-vararg', '--disable=redundant-u-string-prefix,raise-missing-from,keyword-arg-before-vararg',
# XXX acceptable to ignore in the context of ERP5 # XXX acceptable to ignore in the context of ERP5
...@@ -563,6 +564,12 @@ def checkPythonSourceCode(source_code_str, portal_type=None): ...@@ -563,6 +564,12 @@ def checkPythonSourceCode(source_code_str, portal_type=None):
'--disable=duplicate-bases,inconsistent-mro', '--disable=duplicate-bases,inconsistent-mro',
) )
) )
else:
args.extend(
(
'--load-plugins=Products.ERP5Type.patches.pylint_compatibility_disable',
)
)
if portal_type == 'Interface Component': if portal_type == 'Interface Component':
# __init__ method from base class %r is not called # __init__ method from base class %r is not called
args.append('--disable=W0231') args.append('--disable=W0231')
...@@ -575,11 +582,6 @@ def checkPythonSourceCode(source_code_str, portal_type=None): ...@@ -575,11 +582,6 @@ def checkPythonSourceCode(source_code_str, portal_type=None):
# Method should have "self" as first argument (no-self-argument) # Method should have "self" as first argument (no-self-argument)
args.append('--disable=E0213') args.append('--disable=E0213')
try:
from pylint.extensions.bad_builtin import __name__ as ext
args.append('--load-plugins=' + ext)
except ImportError:
pass
try: try:
# Note that we don't run pylint as a subprocess, but directly from # Note that we don't run pylint as a subprocess, but directly from
# ERP5 process, so that pylint can access the code from ERP5Type # ERP5 process, so that pylint can access the code from ERP5Type
......
"""A dummy checker to register messages from pylint3, to be able to
disable the messages on python2 without causing bad-option-value
"""
from __future__ import absolute_import
from pylint import checkers, interfaces
class CompatibilityDisableChecker(checkers.BaseChecker):
name = "compatibility-disable"
msgs = {
"E9990": (
"not-an-iterable",
"not-an-iterable",
"",
),
"E9991": (
"misplaced-bare-raise",
"misplaced-bare-raise",
"",
),
"W9992": (
"unused-private-member",
"unused-private-member",
"",
),
"E9993": (
"using-constant-test",
"using-constant-test",
""
),
"E9994": (
"modified-iterating-list",
"modified-iterating-list",
"",
),
"E9995": (
"unsubscriptable-object",
"unsubscriptable-object",
"",
),
"E9996": (
"invalid-unary-operand-type",
"invalid-unary-operand-type",
"",
),
"E9997": (
"unbalanced-dict-unpacking",
"unbalanced-dict-unpacking",
"",
),
"E9998": (
"self-cls-assignment",
"self-cls-assignment",
"",
),
"E9999": (
"deprecated-class",
"deprecated-class",
"",
),
}
def register(linter):
linter.register_checker(CompatibilityDisableChecker(linter))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment