Commit 3be66ed5 authored by Arnaud Fontaine's avatar Arnaud Fontaine

ZODB Components: Disable some pylint warnings.

Get rid of refactoring/convention/spurious messages (ERP5 Naming Convention
may be added later on). Also, Pylint cannot deal with dynamic accessor/module
generation, so disable these error messages as well.

Also, patch pylint to handle try/except for modules imports
(https://www.logilab.org/ticket/9386).
parent 8e8f13c6
......@@ -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
......
......@@ -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:
......
# -*- 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
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