/ linter_plugin.py
linter_plugin.py
 1  """Let's Encrypt ACME PyLint plugin.
 2  
 3  http://docs.pylint.org/plugins.html
 4  
 5  """
 6  from astroid import MANAGER
 7  from astroid import nodes
 8  
 9  
10  def register(unused_linter):
11      """Register this module as PyLint plugin."""
12  
13  def _transform(cls):
14      # fix the "no-member" error on instances of
15      # letsencrypt.acme.util.ImmutableMap subclasses (instance
16      # attributes are initialized dynamically based on __slots__)
17  
18      # TODO: this is too broad and applies to any tested class...
19  
20      if cls.slots() is not None:
21          for slot in cls.slots():
22              cls.locals[slot.value] = [nodes.EmptyNode()]
23  
24      if cls.name == 'JSONObjectWithFields':
25          # _fields is magically introduced by JSONObjectWithFieldsMeta
26          cls.locals['_fields'] = [nodes.EmptyNode()]
27  
28  
29  MANAGER.register_transform(nodes.Class, _transform)