Hello,
The first patch fixes a minor problem that Pylint 1.0 finds in our code.

The second patch makes make-lint compatible with Pylint 1.0. It contains a workaround for a Pylint bug; before pushing this we should wait for a while to see if a fixed Pylint is released.

--
PetrĀ³
From 969ead2e3fbdf9cfbd6bffefef24316d37803a13 Mon Sep 17 00:00:00 2001
From: Petr Viktorin <pvikt...@redhat.com>
Date: Mon, 19 Aug 2013 12:01:54 +0200
Subject: [PATCH] Remove __all__ specifications in ipaclient and
 ipaserver.install

The __all__ list does not cause submodules to be imported, e.g.
one would still have to `import ipaclient.ipachangeconf` rather than
just `import ipaclient` to use `ipaclient.ipachangeconf`.

Even if they did do anything, the lists were incomplete, and (since
`import *` is not used on these modules) unnecessary.

Pylint 1.0 reports undeclared names in __all__ as a warning.
---
 ipa-client/ipaclient/__init__.py | 3 ---
 ipaserver/install/__init__.py    | 2 --
 2 files changed, 5 deletions(-)

diff --git a/ipa-client/ipaclient/__init__.py b/ipa-client/ipaclient/__init__.py
index 39c97d2fd6b3113eaab6384fe97f0ef27e4e67f3..65ab6ac3ed33541bd8a6d9a50ddc1f04ecaa5e6f 100644
--- a/ipa-client/ipaclient/__init__.py
+++ b/ipa-client/ipaclient/__init__.py
@@ -16,6 +16,3 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
-
-__all__ = ["ipadiscovery", "ipachangeconf"]
-
diff --git a/ipaserver/install/__init__.py b/ipaserver/install/__init__.py
index bc2229415f278dca3294d34578e454f1971a54fc..fc08ea43921b27216df7d5e9d8cba46e1123422a 100644
--- a/ipaserver/install/__init__.py
+++ b/ipaserver/install/__init__.py
@@ -17,5 +17,3 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
-
-__all__ = ["dsinstance", "krbinstance"]
-- 
1.8.3.1

From 67f7a0368bc84ef98c1892401549418f093b79b4 Mon Sep 17 00:00:00 2001
From: Petr Viktorin <pvikt...@redhat.com>
Date: Mon, 19 Aug 2013 12:18:54 +0200
Subject: [PATCH] Make make-lint compatible with Pylint 1.0

Pylint 1.0 was released[0] and it brings some incompatibilities,
as well as a bug[1] that's triggered by FreeIPA code.

This patch updates make-lint to be compatible with Pylint 1.0,
while keeping support for version 0.26.

[0] http://www.logilab.org/blogentry/163292
[1] https://bitbucket.org/logilab/pylint/issue/47

Ticket: https://fedorahosted.org/freeipa/ticket/3865
---
 make-lint | 38 ++++++++++++++++++++++++++++++++++----
 1 file changed, 34 insertions(+), 4 deletions(-)

diff --git a/make-lint b/make-lint
index fd7bea2130b94f07ff3e19f8168f95fa561b50fc..69cce6e5fc3c9ad6ec98634b122dbbec95700ea9 100755
--- a/make-lint
+++ b/make-lint
@@ -28,18 +28,33 @@ from fnmatch import fnmatch, fnmatchcase
 try:
     from pylint import checkers
     from pylint.lint import PyLinter
-    from pylint.reporters.text import ParseableTextReporter
     from pylint.checkers.typecheck import TypeChecker
-    from logilab.astng import Class, Instance, InferenceError
+    try:
+        # Pylint 1.0
+        from astroid import Class, Instance, InferenceError
+        from pylint.reporters.text import TextReporter
+        have_pylint_1_0 = True
+    except ImportError:
+        # Older Pylint
+        from logilab.astng import Class, Instance, InferenceError
+        from pylint.reporters.text import ParseableTextReporter
+        have_pylint_1_0 = False
 except ImportError:
     print >> sys.stderr, "To use {0}, please install pylint.".format(sys.argv[0])
     sys.exit(32)
 
 # File names to ignore when searching for python source files
 IGNORE_FILES = ('.*', '*~', '*.in', '*.pyc', '*.pyo')
 IGNORE_PATHS = ('build', 'rpmbuild', 'dist', 'install/po/test_i18n.py',
     'lite-server.py', 'make-lint', 'make-test', 'ipatests')
 
+# FIXME: The following classes cause the following Pylint error:
+# https://bitbucket.org/logilab/pylint/issue/47
+IGNORE_RELATED_CLASSES = [
+    'urlparse.SplitResult',
+    'ArgSpec.ArgSpec',
+]
+
 class IPATypeChecker(TypeChecker):
     NAMESPACE_ATTRS = ['Command', 'Object', 'Method', 'Property', 'Backend',
         'Updater', 'Advice']
@@ -58,6 +73,11 @@ class IPATypeChecker(TypeChecker):
             'fragment', 'username', 'password', 'hostname', 'port'],
         'urlparse.ParseResult': ['params'],
 
+        # Related to IGNORE_RELATED_CLASSES
+        'urlparse.SplitResult': ['netloc'],
+        'ArgSpec.ArgSpec': ['args'],
+        'ldap.LDAPError': ['args'],
+
         # IPA classes
         'ipalib.base.NameSpace': ['add', 'mod', 'del', 'show', 'find'],
         'ipalib.cli.Collector': ['__options'],
@@ -91,6 +111,11 @@ class IPATypeChecker(TypeChecker):
 
     def _related_classes(self, klass):
         yield klass
+
+        if any(str(klass) == 'Instance of %s' % n
+               for n in IGNORE_RELATED_CLASSES):
+            return
+
         for base in klass.ancestors():
             yield base
 
@@ -222,8 +247,13 @@ def main():
     if options.errors_only:
         linter.disable_noerror_messages()
         linter.enable('F')
-    linter.set_reporter(ParseableTextReporter())
-    linter.set_option('include-ids', True)
+    if have_pylint_1_0:
+        linter.set_reporter(TextReporter())
+        linter.set_option('msg-template',
+                        '{path}:{line}: [{msg_id}({symbol}), {obj}] {msg})')
+    else:
+        linter.set_reporter(ParseableTextReporter())
+        linter.set_option('include-ids', True)
     linter.set_option('reports', False)
     linter.set_option('persistent', False)
 
-- 
1.8.3.1

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to