From 13128464aa82358e344bcaeceb9d86e84cdd0f11 Mon Sep 17 00:00:00 2001 From: Jakub Warmuz Date: Fri, 6 Feb 2015 22:54:28 +0000 Subject: [PATCH] ACME: pylint lint plugin --- .pylintrc | 2 +- letsencrypt/acme/lint.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 letsencrypt/acme/lint.py diff --git a/.pylintrc b/.pylintrc index 44fc15b1c..bf4828e75 100644 --- a/.pylintrc +++ b/.pylintrc @@ -19,7 +19,7 @@ persistent=yes # List of plugins (as comma separated values of python modules names) to load, # usually to register additional checkers. -load-plugins= +load-plugins=letsencrypt.acme.lint [MESSAGES CONTROL] diff --git a/letsencrypt/acme/lint.py b/letsencrypt/acme/lint.py new file mode 100644 index 000000000..63f75d69d --- /dev/null +++ b/letsencrypt/acme/lint.py @@ -0,0 +1,20 @@ +"""Let's Encrypt ACME PyLint plugin. + +http://docs.pylint.org/plugins.html + +""" +from astroid import MANAGER +from astroid import nodes + + +def register(unused_linter): + """Register this module as PyLint plugin.""" + +def _transform(cls): + if (('Message' in cls.basenames or 'ImmutableMap' in cls.basenames or + 'util.ImmutableMap' in cls.basenames) and (cls.slots() is not None)): + for slot in cls.slots(): + cls.locals[slot.value] = [nodes.EmptyNode()] + + +MANAGER.register_transform(nodes.Class, _transform)