Permalink
Switch branches/tags
pylint-version-1.1.0 pylint-version-1.0.0 pylint-version-0.28.0 pylint-version-0.27.0 pylint-version-0.26.0 pylint-version-0.25.2 pylint-version-0.25.1 pylint-version-0.25.0 pylint-version-0.24.0 pylint-version-0.23.0 pylint-version-0.22.0 pylint-version-0.21.4 pylint-version-0.21.3 pylint-version-0.21.2 pylint-version-0.21.1 pylint-version-0.21.0 pylint-version-0.20.0 pylint-version-0.19.0 pylint-version-0.18.1 pylint-version-0_17_0 pylint-version-0_15_2 pylint-version-0_15_1 pylint-version-0_15_0 pylint-version-0_13_0 pylint-debian-version-1.1.0-1 pylint-debian-version-1.0.0-1 pylint-debian-version-0.28.0-1 pylint-debian-version-0.27.0-1 pylint-debian-version-0.26.0-1 pylint-debian-version-0.25.2-1 pylint-debian-version-0.25.1-1 pylint-debian-version-0.25.0-1 pylint-debian-version-0.24.0-1 pylint-debian-version-0.23.0-1 pylint-debian-version-0.22.0-1 pylint-debian-version-0.21.4-1 pylint-debian-version-0.21.3-1 pylint-debian-version-0.21.2-1 pylint-debian-version-0.21.1-1 pylint-debian-version-0.21.0-1 pylint-debian-version-0.20.0-1 pylint-debian-version-0.19.0-1 pylint-debian-version-0.18.1-1 pylint-debian-version-0_15_2-1 pylint-debian-version-0_15_1-1 pylint-debian-version-0_15_0-1 pylint-debian-version-0_13_0-1 pylint-2.1.1 pylint-2.1.0 pylint-2.0.1 pylint-2.0 pylint-2.0.dev1 pylint-2.0.dev pylint-1.9.2 pylint-1.9.1 pylint-1.9 pylint-1.8.4 pylint-1.8.3 pylint-1.8.2 pylint-1.8.1 pylint-1.8.0 pylint-1.7.6 pylint-1.7.5 pylint-1.7.4 pylint-1.7.3 pylint-1.7.2 pylint-1.7.1 pylint-1.7.0 pylint-1.6.5 pylint-1.6.4 pylint-1.6.3 pylint-1.6.2 pylint-1.6.1 pylint-1.6.0 pylint-1.5.6 pylint-1.5.5 pylint-1.5.4 pylint-1.5.3 pylint-1.5.2 pylint-1.5.1 pylint-1.5 pylint-1.4.5 pylint-1.4.4 pylint-1.4.3 pylint-1.4.2 pylint-1.4.1 pylint-1.4 pylint-1.3.1 pylint-1.3 pylint-1.2 before-astroid
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
71 lines (59 sloc) 2.5 KB
import astroid
from pylint.interfaces import IAstroidChecker
from pylint.checkers import BaseChecker
# This is our checker class.
# Checkers should always inherit from `BaseChecker`.
class MyAstroidChecker(BaseChecker):
"""Add class member attributes to the class locals dictionary."""
# This class variable defines the type of checker that we are implementing.
# In this case, we are implementing an AST checker.
__implements__ = IAstroidChecker
# The name defines a custom section of the config for this checker.
name = 'custom'
# The priority indicates the order that pylint will run the checkers.
priority = -1
# This class variable declares the messages (ie the warnings and errors)
# that the checker can emit.
msgs = {
# Each message has a code, a message that the user will see,
# a unique symbol that identifies the message,
# and a detailed help message
# that will be included in the documentation.
'W0001': ('Message that will be emitted',
'message-symbol',
'Message help')
}
# This class variable declares the options
# that are configurable by the user.
options = (
# Each option definition has a name which is used on the command line
# and in config files, and a dictionary of arguments
# (similar to those to those to
# argparse.ArgumentParser.add_argument).
('store-locals-indicator',
{'default': 'properties',
'help': ('The expression name that indicates that the locals should '
'be stored'),
},
),
)
def visit_call(self, node):
"""Called when a :class:`.astroid.node_classes.Call` node is visited.
See :mod:`astroid` for the description of available nodes.
:param node: The node to check.
:type node: astroid.node_classes.Call
"""
if not (isinstance(node.func, astroid.Attribute)
and isinstance(node.func.expr, astroid.Name)
and node.func.expr.name == self.config.store_locals_indicator
and node.func.attrname == 'create'):
return
in_class = node.frame()
for param in node.args:
in_class.locals[param.name] = node
def register(linter):
"""This required method auto registers the checker.
:param linter: The linter to register the checker to.
:type linter: pylint.lint.PyLinter
"""
linter.register_checker(MyAstroidChecker(linter))