diff --git a/product/ERP5Type/__init__.py b/product/ERP5Type/__init__.py index f37419248f47b835a1784b34adcaee7245ba8144..fa39dfc8535faf6fabdbc594b52d53066a74fcb0 100644 --- a/product/ERP5Type/__init__.py +++ b/product/ERP5Type/__init__.py @@ -30,7 +30,7 @@ ERP5Type is provides a RAD environment for Zope / CMF All ERP5 classes derive from ERP5Type """ -from patches import python +from patches import python, pylint from zLOG import LOG, INFO DISPLAY_BOOT_PROCESS = False diff --git a/product/ERP5Type/mixin/component.py b/product/ERP5Type/mixin/component.py index e51f58e25e256a82ab3ffe4d28efb0aeaca62f7e..2e26741b755df265e69d0a9ba5c1061d7e3484f4 100644 --- a/product/ERP5Type/mixin/component.py +++ b/product/ERP5Type/mixin/component.py @@ -321,7 +321,40 @@ class ComponentMixin(PropertyRecordableMixin, Base): input_file.seek(0) Run([input_file.name, '--reports=n', '--indent-string=" "', '--zope=y', - '--disable=C'], reporter=TextReporter(output_file), exit=False) + # Disable Refactoring and Convention messages which are too verbose + # TODO-arnau: Should perphaps check ERP5 Naming Conventions? + '--disable=R,C', + # 'String statement has no effect': eg docstring at module level + '--disable=W0105', + # 'Using possibly undefined loop variable %r': Spurious warning + # (loop variables used after the loop) + '--disable=W0631', + # 'fixme': No need to display TODO/FIXME entry in warnings + '--disable=W0511', + # 'Unused argument %r': Display for readability or when defining abstract methods + '--disable=W0613', + # 'Catching too general exception %s': Too coarse + # TODO-arnau: Should consider raise in except + '--disable=W0703', + # 'Used * or ** magic': commonly used in ERP5 + '--disable=W0142', + # 'Class has no __init__ method': Spurious warning + '--disable=W0232', + # 'Attribute %r defined outside __init__': Spurious warning + '--disable=W0201', + # Dynamic class generation so some attributes may not be found + # TODO-arnau: Enable it properly would require inspection API + # '%s %r has no %r member' + '--disable=E1101,E1103', + # 'No name %r in module %r' + '--disable=E0611', + # map and filter should not be considered bad as in some cases + # map is faster than its recommended replacement (list + # comprehension) + '--bad-functions=apply,input', + # string module does not only contain deprecated functions... + '--deprecated-modules=regsub,TERMIOS,Bastion,rexec'], + reporter=TextReporter(output_file), exit=False) output_file.reset() for line in output_file: diff --git a/product/ERP5Type/patches/pylint.py b/product/ERP5Type/patches/pylint.py new file mode 100644 index 0000000000000000000000000000000000000000..6bbee6aedd79ae23390a9deec7526b325b746ede --- /dev/null +++ b/product/ERP5Type/patches/pylint.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# +# Copyright (c) 2003-2012 LOGILAB S.A. (Paris, FRANCE). +# http://www.logilab.fr/ -- mailto:contact@logilab.fr +# +# Copyright (c) 2013 Nexedi SA and Contributors. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +from __future__ import absolute_import + +try: + from pylint.checkers import imports + import astroid +except ImportError: + pass +else: + def get_imported_module(self, modnode, importnode, modname): + try: + return importnode.do_import_module(modname) + except astroid.InferenceError, ex: + # BEGIN + # Handle ImportError try/except checking for missing module before + # falling back to code handling such case (#9386) + pnode = importnode.parent + if pnode and isinstance(pnode, astroid.TryExcept): + for handler in pnode.handlers: + # Handling except: + if not handler.type: + return + + # Handling ImportError and its Exception base classes + for klass in ImportError.mro(): + if klass is object: + break + elif klass.__name__ == handler.type.name: + return + # END + + if str(ex) != modname: + args = '%r (%s)' % (modname, ex) + else: + args = repr(modname) + self.add_message("F0401", args=args, node=importnode) + + imports.ImportsChecker.get_imported_module = get_imported_module