chiark / gitweb /
jenkins-build: make pylint handle the hashlib hash classes properly
authorHans-Christoph Steiner <hans@eds.org>
Wed, 2 Apr 2014 23:53:53 +0000 (19:53 -0400)
committerHans-Christoph Steiner <hans@eds.org>
Thu, 3 Apr 2014 16:33:22 +0000 (12:33 -0400)
hashlib uses some magic to load whatever is built into the local openssl.
pylint gets confused by this, so we need a pylint plugin to trick pylint
into thinking everything is good.

.pylint-plugins/astng_hashlib.py [new file with mode: 0644]
jenkins-build

diff --git a/.pylint-plugins/astng_hashlib.py b/.pylint-plugins/astng_hashlib.py
new file mode 100644 (file)
index 0000000..f4b7871
--- /dev/null
@@ -0,0 +1,39 @@
+#
+# started from http://www.logilab.org/blogentry/78354
+#
+
+from logilab.astng import MANAGER
+from logilab.astng.builder import ASTNGBuilder
+
+def hashlib_transform(module):
+    if module.name == 'hashlib':
+        fake = ASTNGBuilder(MANAGER).string_build('''
+
+class fakehash(object):
+  digest_size = -1
+  def __init__(self, value): pass
+  def digest(self):
+    return u''
+  def hexdigest(self):
+    return u''
+  def update(self, value): pass
+
+class md5(fakehash):
+  pass
+
+class sha1(fakehash):
+  pass
+
+class sha256(fakehash):
+  pass
+
+''')
+        for hashfunc in ('sha256', 'sha1', 'md5'):
+            module.locals[hashfunc] = fake.locals[hashfunc]
+
+def register(linter):
+    """called when loaded by pylint --load-plugins, register our tranformation
+    function here
+    """
+    MANAGER.register_transformer(hashlib_transform)
+
index 281aa1d484cc8feb64df1c4441ca95bf3323a8f8..7decda4bf0045caa6510ede7a663225be7745950 100755 (executable)
@@ -72,13 +72,11 @@ pyflakes fdroid makebuildserver fdroidserver/*.py setup.py
 
 cd $WORKSPACE
 set +e
-# disable E1101 until there is a plugin to handle this properly:
-#   Module 'sys' has no '_MEIPASS' member
-# disable F0401 until there is a plugin to handle this properly:
-#   keysync-gui:25: [F] Unable to import 'ordereddict'
 # use the virtualenv python so pylint checks against its installed libs
-python /usr/bin/pylint --output-format=parseable --reports=n \
-    fdroidserver/*.py fdroid makebuildserver setup.py > $WORKSPACE/pylint.parseable
+    PYTHONPATH=$WORKSPACE/.pylint-plugins python /usr/bin/pylint \
+        --output-format=parseable --reports=n \
+        --load-plugins astng_hashlib \
+        fdroidserver/*.py fdroid makebuildserver setup.py > $WORKSPACE/pylint.parseable
 
 # to only tell jenkins there was an error if we got ERROR or FATAL, uncomment these:
 [ $(($? & 1)) = "1" ] && echo "FATALs found"