[elbe-devel] [PATCH 21/25] pylint: locally disable no-member complaints

Torben Hohn torben.hohn at linutronix.de
Wed Aug 22 10:42:22 CEST 2018


pylint does not see when members are created programmatically,
or when imports might actually fail.

pylint complains:
----------------------------------------------------------------------------------------------------------------------
************* Module elbepack.rpcaptcache
elbepack/rpcaptcache.py:285: [E1101(no-member), get_rpcaptcache] Instance of 'MyMan' has no 'RPCAPTCache' member
************* Module elbepack.pkgutils
elbepack/pkgutils.py:13: [E1101(no-member), ] Module 'urllib' has no 'request' member
************* Module elbepack.virtapt
elbepack/virtapt.py:283: [E1101(no-member), get_virtaptcache] Instance of 'MyMan' has no 'VirtRPCAPTCache' member
----------------------------------------------------------------------------------------------------------------------

disable these false positives.

Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
---
 elbepack/pkgutils.py    | 6 ++++++
 elbepack/rpcaptcache.py | 5 +++++
 elbepack/virtapt.py     | 5 +++++
 3 files changed, 16 insertions(+)

diff --git a/elbepack/pkgutils.py b/elbepack/pkgutils.py
index 70ec2561..5049f188 100644
--- a/elbepack/pkgutils.py
+++ b/elbepack/pkgutils.py
@@ -10,6 +10,12 @@ from __future__ import print_function
 # different module names in python 2 and 3
 try:
     import urllib.request
+
+    # when running inside pylint this import fails
+    # disable no-member here
+    #
+    # pylint: disable=no-member
+
     urlopen = urllib.request.urlopen
 except ImportError:
     import urllib2
diff --git a/elbepack/rpcaptcache.py b/elbepack/rpcaptcache.py
index eb72fe81..74cad511 100644
--- a/elbepack/rpcaptcache.py
+++ b/elbepack/rpcaptcache.py
@@ -282,4 +282,9 @@ def get_rpcaptcache(
     mm = MyMan()
     mm.start()
 
+    # Disable false positive, because pylint can not
+    # see the creation of MyMan.RPCAPTCache by
+    # MyMan.register()
+    #
+    # pylint: disable=no-member
     return mm.RPCAPTCache(rfs, log, arch, notifier, norecommend, noauth)
diff --git a/elbepack/virtapt.py b/elbepack/virtapt.py
index 1ddaa584..b053551f 100644
--- a/elbepack/virtapt.py
+++ b/elbepack/virtapt.py
@@ -280,4 +280,9 @@ def get_virtaptcache(arch, suite, sources, prefs, keylist=[]):
     mm = MyMan()
     mm.start()
 
+    # Disable false positive, because pylint can not
+    # see the creation of MyMan.VirtRPCAPTCache by
+    # MyMan.register()
+    #
+    # pylint: disable=no-member
     return mm.VirtRPCAPTCache(arch, suite, sources, prefs, keylist)
-- 
2.11.0




More information about the elbe-devel mailing list