URL: https://github.com/freeipa/freeipa/pull/2137
Author: tiran
 Title: #2137: pylint 2.0: node.path is a list
Action: opened

PR body:
"""
In pylint 2.0 and astroid 2.0, node.path has become a list. It's usually
a list of one element unless namespace packages are involved.

See 
https://github.com/PyCQA/astroid/commit/7f46f9341cc54bbe6763409c4ca7ea3adfec098a#diff-f0ac879524bcb98964f7d8738a084820

See: https://pagure.io/freeipa/issue/7614
Signed-off-by: Christian Heimes <chei...@redhat.com>
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/2137/head:pr2137
git checkout pr2137
From 85c240b333467659b78344184a7f170f8edc8a87 Mon Sep 17 00:00:00 2001
From: Christian Heimes <chei...@redhat.com>
Date: Wed, 11 Jul 2018 11:58:40 +0200
Subject: [PATCH] pylint 2.0: node.path is a list

In pylint 2.0 and astroid 2.0, node.path has become a list. It's usually
a list of one element unless namespace packages are involved.

See https://github.com/PyCQA/astroid/commit/7f46f9341cc54bbe6763409c4ca7ea3adfec098a#diff-f0ac879524bcb98964f7d8738a084820

See: https://pagure.io/freeipa/issue/7614
Signed-off-by: Christian Heimes <chei...@redhat.com>
---
 pylint_plugins.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/pylint_plugins.py b/pylint_plugins.py
index dc32e5a920..896f954abe 100644
--- a/pylint_plugins.py
+++ b/pylint_plugins.py
@@ -364,6 +364,11 @@ def open(self):
 
     def _get_forbidden_import_rule(self, node):
         path = node.path
+        if path and isinstance(path, list):
+            # In pylint 2.0, path is a list with one element. Namespace
+            # packages may contain more than one element, but we can safely
+            # ignore them, as they don't contain code.
+            path = path[0]
         if path:
             path = os.path.abspath(path)
             while path.startswith(self._dir):
_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/freeipa-devel@lists.fedorahosted.org/message/NJPPC4Q4ZMGTL2PQXL4EPBU45COC5LBK/

Reply via email to